Update README.md to include project description, developer documentation links, and license information.
CI / build-test (push) Successful in 1m6s

This commit is contained in:
Leonid Pershin
2026-06-11 04:03:07 +03:00
parent 31aba3aeee
commit ff2231a8ab
72 changed files with 4113 additions and 0 deletions
@@ -0,0 +1,67 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using MrGameEng.Input;
using Xunit;
namespace MrGameEng.Input.Tests;
public class InputManagerTests
{
private static MouseState Mouse(int x = 0, int y = 0, int wheel = 0, ButtonState left = ButtonState.Released) =>
new(x, y, wheel, left, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
private static void Frame(InputManager input, KeyboardState keyboard = default, MouseState mouse = default) =>
input.Apply(keyboard, mouse, GamePadState.Default);
[Fact]
public void KeyPressed_OnlyOnTheFrameItGoesDown()
{
var input = new InputManager();
Frame(input, new KeyboardState(Keys.Space));
Assert.True(input.IsKeyPressed(Keys.Space));
Assert.True(input.IsKeyDown(Keys.Space));
Frame(input, new KeyboardState(Keys.Space));
Assert.False(input.IsKeyPressed(Keys.Space));
Assert.True(input.IsKeyDown(Keys.Space));
}
[Fact]
public void KeyReleased_OnlyOnTheFrameItGoesUp()
{
var input = new InputManager();
Frame(input, new KeyboardState(Keys.A));
Frame(input);
Assert.True(input.IsKeyReleased(Keys.A));
Frame(input);
Assert.False(input.IsKeyReleased(Keys.A));
}
[Fact]
public void MouseDeltaAndWheelDelta_ComputedBetweenFrames()
{
var input = new InputManager();
Frame(input, mouse: Mouse(x: 10, y: 10, wheel: 0));
Frame(input, mouse: Mouse(x: 25, y: 5, wheel: 120));
Assert.Equal(new Point(15, -5), input.MouseDelta);
Assert.Equal(120, input.WheelDelta);
Assert.Equal(new Point(25, 5), input.MousePosition);
}
[Fact]
public void MousePressed_DetectsLeftButtonEdge()
{
var input = new InputManager();
Frame(input, mouse: Mouse());
Frame(input, mouse: Mouse(left: ButtonState.Pressed));
Assert.True(input.IsMousePressed(MouseButton.Left));
Assert.False(input.IsMousePressed(MouseButton.Right));
}
}