MouseMovementTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Input.Tests MouseMovementTriggerTests

Namespace: DeltaEngine.Input.Tests
Assembly: DeltaEngine.Input.Tests (in DeltaEngine.Input.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class MouseMovementTriggerTests : TestWithMocksOrVisually

The MouseMovementTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodMouseMovementTriggerTests
Initializes a new instance of the MouseMovementTriggerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreate
Public methodCreateFromAttributes
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodMoveMouseToUpdatePositionOfCircle
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodUpdatePosition
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void MoveMouseToUpdatePositionOfCircle()
{
    var ellipse = new Ellipse(new Rectangle(-0.1f, -0.1f, 0.1f, 0.1f), Color.Red);
    new Command(pos => ellipse.Center = pos).Add(new MouseMovementTrigger());
}
[Test, CloseAfterFirstFrame]
public void UpdatePosition()
{
    Vector2D position = Vector2D.Zero;
    new Command(pos => position = pos).Add(new MouseMovementTrigger());
    Assert.AreEqual(Vector2D.Zero, position);
    var mockMouse = Resolve<Mouse>() as MockMouse;
    if (mockMouse == null)
        return; //ncrunch: no coverage
    mockMouse.SetNativePosition(new Vector2D(0.4f, 0.6f));
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(new Vector2D(0.4f, 0.6f), position);
}
[Test, CloseAfterFirstFrame]
public void Create()
{
    var trigger = new MouseMovementTrigger();
    Assert.AreEqual(Vector2D.Zero, trigger.Movement);
    Assert.IsFalse(trigger.IsPauseable);
}
[Test, CloseAfterFirstFrame]
public void CreateFromAttributes()
{
    var trigger = new MouseMovementTrigger(new Dictionary<string, string>());
    Assert.AreEqual(Vector2D.Zero, trigger.Movement);
    Assert.Throws<MouseMovementTrigger.MouseMovementTriggerHasNoParameters>(
        () => new MouseMovementTrigger(new Dictionary<string, string> { { "a", "b" } }));
}
See Also