MouseButtonTrigger State Property Delta Engine Documentation

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

public State State { get; }

Property Value

Type: State
Remarks

Tests: DeltaEngine.Input.Tests.MouseButtonTriggerTests
Examples

2 unit tests call DeltaEngine.Input.MouseButtonTrigger.State
[Test, CloseAfterFirstFrame]
public void Create()
{
    var trigger = new MouseButtonTrigger(MouseButton.Right, State.Pressed);
    Assert.AreEqual(MouseButton.Right, trigger.Button);
    Assert.AreEqual(State.Pressed, trigger.State);
    Assert.AreEqual(MouseButton.Left, new MouseButtonTrigger().Button);
    Assert.AreEqual(State.Pressing, new MouseButtonTrigger().State);
    Assert.AreEqual(MouseButton.Left, new MouseButtonTrigger(State.Pressed).Button);
    Assert.AreEqual(State.Pressed, new MouseButtonTrigger(State.Pressed).State);
}
    [Test, CloseAfterFirstFrame]
    public void CreateFromAttributes()
    {
        var trigger = new MouseButtonTrigger(new Dictionary<string, string>
            {
                { "Button", "Right" },
                { "State", " Pressed" }
            });
        Assert.AreEqual(MouseButton.Right, trigger.Button);
        Assert.AreEqual(State.Pressed, trigger.State);
        Assert.Throws<MouseButtonTrigger.CannotCreateMouseButtonTriggerWithoutButton>(
            () => new MouseButtonTrigger(new Dictionary<string, string>()));
    }

    [Test, CloseAfterFirstFrame]
    public void IsTriggered()
    {
        if (!IsMockResolver)
            return; //ncrunch: no coverage 
        var trigger = new MouseButtonTrigger(MouseButton.Right, State.Pressed);
        bool invoked = false;
        trigger.Invoked += () => invoked = true;
        var mouse = Resolve<MockMouse>();
        mouse.SetButtonState(MouseButton.Right, State.Pressed);
        AdvanceTimeAndUpdateEntities();
        Assert.True(invoked);
    }
}
See Also