TouchPositionTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

public class TouchPositionTriggerTests : TestWithMocksOrVisually

The TouchPositionTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodTouchPositionTriggerTests
Initializes a new instance of the TouchPositionTriggerTests class
Top
Methods

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

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void ShowRedCircleOnTouchWithMovement()
{
    var ellipse = new Ellipse(new Rectangle(-0.1f, -0.1f, 0.1f, 0.1f), Color.Red);
    new Command(pos => ellipse.Center = pos).Add(new TouchPositionTrigger(State.Pressed));
}
[Test, CloseAfterFirstFrame]
public void Create()
{
    var trigger = new TouchPositionTrigger(State.Pressed);
    Assert.AreEqual(State.Pressed, trigger.State);
}
[Test, CloseAfterFirstFrame]
public void CreateFromAttributes()
{
    var trigger =
        new TouchPositionTrigger(new Dictionary<string, string> { { "State", "Pressed" } });
[Test]
public void InvokeTouch()
{
    var touch = Resolve<Touch>() as MockTouch;
    if (touch == null)
        return; //ncrunch: no coverage 
    var trigger = new TouchPositionTrigger(State.Pressed);
    bool wasInvoked = false;
    new Command(() => wasInvoked = true).Add(trigger);
    touch.SetTouchState(0, State.Pressed, Vector2D.Half);
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(wasInvoked);
}
[Test]
public void TouchPositionTriggerState()
{
    var trigger = new TouchPositionTrigger(new Dictionary<string, string>());
    Assert.AreEqual(State.Pressing, trigger.State);
}
See Also