示例#1
0
        public void HasCalledInitializeStateTrue_WhenInitializeStateCalled()
        {
            // Arrange
            TestState01 testState01 = new TestState01();
            TestState02 testState02 = new TestState02();

            // Act
            StateMachine stateMachine = new StateMachine(new List <IState> {
                testState01, testState02
            });

            // Assert
            Assert.That(testState01.HasCalledInitializeState, Is.True);
            Assert.That(testState01.HasCalledEnterState, Is.False);
            Assert.That(testState01.HasCalledUpdateState, Is.False);
            Assert.That(testState01.HasCalledExitState, Is.False);
            Assert.That(testState01.HasCalledDestoyState, Is.False);
        }
示例#2
0
        public void FullMethodLifecycleCalled_WhenCalled()
        {
            // Arrange
            TestState01 testState01 = new TestState01();
            TestState02 testState02 = new TestState02();


            // Act
            StateMachine stateMachine = new StateMachine(new List <IState> {
                testState01, testState02
            });

            stateMachine.CurrentStateType = typeof(TestState01);
            stateMachine.UpdateStates();
            stateMachine.CurrentStateType = typeof(TestState02);
            stateMachine.DestroyStates();

            // Assert
            Assert.That(testState01.HasCalledInitializeState, Is.True);
            Assert.That(testState01.HasCalledEnterState, Is.True);
            Assert.That(testState01.HasCalledUpdateState, Is.True);
            Assert.That(testState01.HasCalledExitState, Is.True);
            Assert.That(testState01.HasCalledDestoyState, Is.True);
        }