InputDevice IsAvailable Property Delta Engine Documentation

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

public abstract bool IsAvailable { get; protected set; }

Property Value

Type: Boolean
Remarks

Tests: DeltaEngine.Input.Tests.GamePadTests
Remarks

Tests: DeltaEngine.Input.Tests.TouchTests
Examples

2 unit tests call DeltaEngine.Input.InputDevice.IsAvailable
[Test, CloseAfterFirstFrame]
public void TestGamePadButtonPress()
{
    bool isPressed = false;
    new Command(() => isPressed = true).Add(new GamePadButtonTrigger(GamePadButton.A,
        State.Pressed));
    Assert.IsFalse(isPressed);
    var mockGamePad = Resolve<GamePad>() as MockGamePad;
    if (mockGamePad == null)
        return; //ncrunch: no coverage
    mockGamePad.SetGamePadState(GamePadButton.A, State.Pressed);
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(isPressed);
    Assert.IsTrue(mockGamePad.IsAvailable);
}
[Test]
public void CheckGamePadIsAvailable()
{
    var gamePad = Resolve<GamePad>();
    if (gamePad is MockGamePad)
        ((MockGamePad)gamePad).SetUnavailable();
    Assert.IsFalse(gamePad.IsAvailable);
}
Examples

1 unit tests call DeltaEngine.Input.InputDevice.IsAvailable
[Test, CloseAfterFirstFrame]
public void TestPositionAndState()
{
    bool isTouched = false;
    new Command(() => isTouched = true).Add(new TouchPressTrigger(State.Pressed));
    Assert.IsFalse(isTouched);
    var mockTouch = Resolve<Touch>() as MockTouch;
    if (mockTouch == null)
        return; //ncrunch: no coverage
    Assert.NotNull(mockTouch);
    Assert.AreEqual(State.Released, mockTouch.GetState(0));
    Assert.True(mockTouch.IsAvailable);
}
See Also