MouseFlickTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

public class MouseFlickTriggerTests : TestWithMocksOrVisually

The MouseFlickTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodMouseFlickTriggerTests
Initializes a new instance of the MouseFlickTriggerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreation
Public methodFlickWithMouse
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 methodShowRedCircleOnFlick
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void ShowRedCircleOnFlick()
{
    new FontText(Font.Default, "Flick screen to show red circle", Rectangle.One);
    var ellipse = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Red);
    new Command(() => ellipse.Center = Vector2D.Half).Add(new MouseFlickTrigger());
    new Command(() => ellipse.Center = Vector2D.Zero).Add(new MouseButtonTrigger(State.Released));
}
[Test]
public void FlickWithMouse()
{
    var trigger = new MouseFlickTrigger();
    var mouse = Resolve<Mouse>() as MockMouse;
    if (mouse == null)
        return; //ncrunch: no coverage 
    bool flickHappened = false;
    trigger.Invoked += () => flickHappened = true;
    AdvanceMouseTick(mouse, State.Pressing, new Vector2D(0.5f, 0.5f));
    Assert.IsFalse(flickHappened);
    Assert.AreEqual(0.0f, trigger.PressTime);
    Assert.AreEqual(new Vector2D(0.5f, 0.5f), trigger.StartPosition);
    AdvanceMouseTick(mouse, State.Pressed, new Vector2D(0.52f, 0.5f));
    Assert.IsFalse(flickHappened);
    AdvanceMouseTick(mouse, State.Releasing, new Vector2D(0.8f, 0.8f));
    Assert.IsTrue(flickHappened);
    Assert.AreEqual(new Vector2D(0.5f, 0.5f), trigger.StartPosition);
}
[Test]
public void Creation()
{
    Assert.DoesNotThrow(() => new MouseFlickTrigger());
    Assert.Throws<MouseFlickTrigger.MouseFlickTriggerHasNoParameters>(
        () => new MouseFlickTrigger(new Dictionary<string, string> { { "Button", "Left" } }));
}
See Also