TouchDragDropTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

public class TouchDragDropTriggerTests : TestWithMocksOrVisually

The TouchDragDropTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodTouchDragDropTriggerTests
Initializes a new instance of the TouchDragDropTriggerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreate
Public methodCreateFromAttributes
Public methodCreateTouchDragDropTriggerFromString
Public methodDragDropCloseToStartPointWillDoNothing
Public methodDragDropTouchInsideStartArea
Public methodDragDropTouchOutsideStartArea
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 methodSetUp
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void DragDropTouchOutsideStartArea()
{
    if (touch == null)
        return; //ncrunch: no coverage
    Vector2D startPoint = -Vector2D.One;
    new Command(position => { startPoint = position; }).Add(
        new TouchDragDropTrigger(Rectangle.HalfCentered));
    SetTouchState(State.Pressing, Vector2D.Zero);
    SetTouchState(State.Pressed, Vector2D.One);
    SetTouchState(State.Releasing, Vector2D.One);
    SetTouchState(State.Released, Vector2D.One);
    Assert.AreEqual(-Vector2D.One, startPoint);
}
[Test, CloseAfterFirstFrame]
public void DragDropTouchInsideStartArea()
{
    if (touch == null)
        return; //ncrunch: no coverage
    Vector2D startPoint = -Vector2D.One;
    new Command(position => { startPoint = position; }).Add(
        new TouchDragDropTrigger(Rectangle.HalfCentered));
    SetTouchState(State.Pressing, Vector2D.Half);
    SetTouchState(State.Pressed, Vector2D.One);
    SetTouchState(State.Releasing, Vector2D.One);
    Assert.AreEqual(Vector2D.Half, startPoint);
}
[Test, CloseAfterFirstFrame]
public void Create()
{
    var trigger = new TouchDragDropTrigger(Rectangle.One);
    Assert.AreEqual(Rectangle.One, trigger.StartArea);
    Assert.AreEqual(Vector2D.Unused, trigger.StartDragPosition);
}
[Test, CloseAfterFirstFrame]
public void CreateFromAttributes()
{
    var trigger = new TouchDragDropTrigger(new Dictionary<string, string>
        {
            { "StartArea", new Rectangle(0.1f, 0.2f, 0.3f, 0.4f).ToString() }
        });
    Assert.AreEqual(new Rectangle(0.1f, 0.2f, 0.3f, 0.4f), trigger.StartArea);
    Assert.AreEqual(Vector2D.Unused, trigger.StartDragPosition);
}
    [Test, CloseAfterFirstFrame]
    public void DragDropCloseToStartPointWillDoNothing()
    {
        if (touch == null)
            return; //ncrunch: no coverage
        Vector2D startPoint = -Vector2D.One;
        new Command(position => //ncrunch: no coverage start
            { startPoint = position; }).Add(new TouchDragDropTrigger(Rectangle.HalfCentered));
        //ncrunch: no coverage end
        SetTouchState(State.Pressing, Vector2D.Half);
        SetTouchState(State.Pressed, Vector2D.Half);
        SetTouchState(State.Releasing, Vector2D.Half);
        Assert.AreEqual(-Vector2D.One, startPoint);
    }

    [Test, CloseAfterFirstFrame]
    public void CreateTouchDragDropTriggerFromString()
    {
        var startArea = Rectangle.One;
        var trigger = new TouchDragDropTrigger(new Dictionary<string, string>
            { { "StartArea", startArea.ToString() } });
        Assert.AreEqual(startArea, trigger.StartArea);
    }
}
[Test, CloseAfterFirstFrame]
public void CreateTouchDragDropTriggerFromString()
{
    var startArea = Rectangle.One;
    var trigger = new TouchDragDropTrigger(new Dictionary<string, string>
        { { "StartArea", startArea.ToString() } });
    Assert.AreEqual(startArea, trigger.StartArea);
}
See Also