public void TestSwitchState_FromNullToNull_ThrowsException()
    {
        TestSwitchableStateEngine engine = new TestSwitchableStateEngine();

        Assert.That(engine.GetCurState(), Is.Null);

        engine.TrySwitchState(null);
    }
    public void TestSwitchState_FromAStateToSameState_CurStateRemainsState()
    {
        TestSwitchableStateEngine engine = new TestSwitchableStateEngine();
        ITestSwitchableState      state  = Substitute.For <ITestSwitchableState>();

        engine.TrySwitchState(state);

        Assert.That(engine.GetCurState(), Is.SameAs(state));
    }
    public void TestSwitchState_FromStateToDiffStateOfDiffType_TransitionSuccessful()
    {
        TestSwitchableStateEngine engine = new TestSwitchableStateEngine();
        ITestSwitchableState      stateA = Substitute.For <ITestSwitchableStateA>();
        ITestSwitchableState      stateB = Substitute.For <ITestSwitchableStateB>();

        engine.TrySwitchState(stateA);

        engine.TrySwitchState(stateB);

        Assert.That(engine.GetCurState(), Is.SameAs(stateB));
        stateA.Received(1).OnEnter();
        stateA.Received(1).OnExit();
        stateB.Received(1).OnEnter();
    }
    public void Constructor_WhenCalled_CurStateIsNull()
    {
        TestSwitchableStateEngine engine = new TestSwitchableStateEngine();

        Assert.That(engine.GetCurState(), Is.Null);
    }