MouseTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  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

public class MouseTests : TestWithMocksOrVisually

The MouseTests type exposes the following members.

Constructors

  NameDescription
Public methodMouseTests
Initializes a new instance of the MouseTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodGetButtonState
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodScrollWheelUpAndDown
Public methodSetButtonState
Public methodSetUp
Public methodShowScrollWheelValue
Public methodTestLeftMouseButtonClickPassingAction
Public methodTestLeftMouseButtonClickPassingPositionAction
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
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