MouseHoverTriggerTests ClassDelta Engine Documentation
Inheritance Hierarchy

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

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

public class MouseHoverTriggerTests : TestWithMocksOrVisually

The MouseHoverTriggerTests type exposes the following members.

Constructors

  NameDescription
Public methodMouseHoverTriggerTests
Initializes a new instance of the MouseHoverTriggerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCountdownOnMouseHover
Public methodCreate
Public methodCreateFromAttributes
Public methodHoverDoesntTriggersIfMouseMoves
Public methodHoverTriggersIfMouseDoesntMove
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.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test]
public void CountdownOnMouseHover()
{
    var trigger = new MouseHoverTrigger(3.0f);
    new Countdown(new FontText(Font.Default, "", Rectangle.One), trigger);
    var drawArea = Rectangle.One;
    var counter = 0;
    var text = new FontText(Font.Default, "", drawArea.Move(new Vector2D(0.0f, 0.1f)));
    new Command(() => text.Text = "MouseHover triggered " + ++counter + " times.").Add(trigger);
}
[Test, CloseAfterFirstFrame]
public void HoverTriggersIfMouseDoesntMove()
{
    bool isTriggered = false;
    new Command(() => isTriggered = true).Add(new MouseHoverTrigger());
    Resolve<Mouse>().SetNativePosition(Vector2D.Zero);
    AdvanceTimeAndUpdateEntities(1.0f);
    Assert.IsFalse(isTriggered);
    AdvanceTimeAndUpdateEntities(1.0f);
    Assert.IsTrue(isTriggered);
}
[Test, CloseAfterFirstFrame]
public void HoverDoesntTriggersIfMouseMoves()
{
    bool isTriggered = false;
    new Command(() => isTriggered = true).Add(new MouseHoverTrigger());
    Resolve<Mouse>().SetNativePosition(Vector2D.Zero);
    AdvanceTimeAndUpdateEntities(0.5f);
    Resolve<Mouse>().SetNativePosition(Vector2D.One);
    AdvanceTimeAndUpdateEntities(0.5f);
    Assert.IsFalse(isTriggered);
}
[Test, CloseAfterFirstFrame]
public void Create()
{
    var trigger = new MouseHoverTrigger(3.0f);
    Assert.AreEqual(3.0f, trigger.HoverTime);
}
[Test, CloseAfterFirstFrame]
public void CreateFromAttributes()
{
    var trigger =
        new MouseHoverTrigger(new Dictionary<string, string> { { "HoverTime", "3.0" } });
See Also