Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Input.Tests MouseTests
Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The MouseTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MouseTests | Initializes a new instance of the MouseTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
GetButtonState | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) | |
ScrollWheelUpAndDown | ||
SetButtonState | ||
SetUp | ||
ShowScrollWheelValue | ||
TestLeftMouseButtonClickPassingAction | ||
TestLeftMouseButtonClickPassingPositionAction |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void TestLeftMouseButtonClickPassingAction() { new Command(() => isClicked = true).Add(new MouseButtonTrigger(MouseButton.Left, State.Pressed)); TestCommand(); }
[Test, CloseAfterFirstFrame] public void TestLeftMouseButtonClickPassingPositionAction() { new Command(delegate(Vector2D point) { isClicked = true; }).Add( new MouseButtonTrigger(MouseButton.Left, State.Pressed)); TestCommand(); }
[Test, CloseAfterFirstFrame] public void GetButtonState() { var mouse = Resolve<Mouse>(); Assert.AreEqual(State.Released, mouse.GetButtonState(MouseButton.Left)); Assert.AreEqual(State.Released, mouse.GetButtonState(MouseButton.Middle)); Assert.AreEqual(State.Released, mouse.GetButtonState(MouseButton.Right)); Assert.AreEqual(State.Released, mouse.GetButtonState(MouseButton.X1)); Assert.AreEqual(State.Released, mouse.GetButtonState(MouseButton.X2)); }
[Test, CloseAfterFirstFrame] public void SetButtonState() { var mockMouse = Resolve<Mouse>() as MockMouse; if (mockMouse == null) return; //ncrunch: no coverage mockMouse.SetButtonState(MouseButton.Left, State.Pressed); Assert.AreEqual(State.Pressed, mockMouse.GetButtonState(MouseButton.Left)); mockMouse.SetButtonState(MouseButton.Middle, State.Pressed); Assert.AreEqual(State.Pressed, mockMouse.GetButtonState(MouseButton.Middle)); mockMouse.SetButtonState(MouseButton.Right, State.Pressed); Assert.AreEqual(State.Pressed, mockMouse.GetButtonState(MouseButton.Right)); mockMouse.SetButtonState(MouseButton.X1, State.Pressed); Assert.AreEqual(State.Pressed, mockMouse.GetButtonState(MouseButton.X1)); mockMouse.SetButtonState(MouseButton.X2, State.Pressed); Assert.AreEqual(State.Pressed, mockMouse.GetButtonState(MouseButton.X2)); }
[Test, CloseAfterFirstFrame] public void ScrollWheelUpAndDown() { var mockMouse = Resolve<Mouse>() as MockMouse; if (mockMouse == null) return; //ncrunch: no coverage Assert.AreEqual(0, mockMouse.ScrollWheelValue); mockMouse.ScrollUp(); Assert.AreEqual(1, mockMouse.ScrollWheelValue); mockMouse.ScrollDown(); Assert.AreEqual(0, mockMouse.ScrollWheelValue); }
[Test] public void ShowScrollWheelValue() { var mouse = Resolve<Mouse>(); var text = new FontText(Font.Default, "Scroll Mouse Wheel!", Rectangle.One); new Command(() => text.Text = "Scroll Wheel Value: " + mouse.ScrollWheelValue).Add( new MouseZoomTrigger()); }
See Also