public void ChangeState() { TestStateMachine stateMachine = new TestStateMachine(); stateMachine.Start(); stateMachine.StartMachine(); Assert.That(stateMachine.GetState(), Is.EqualTo(StateMachineTestStates.Initial)); stateMachine.ChangeState(StateMachineTestStates.State); Assert.That(stateMachine.GetState(), Is.EqualTo(StateMachineTestStates.State)); stateMachine.StopMachine(); stateMachine.StartMachine(); Assert.That(stateMachine.GetState(), Is.EqualTo(StateMachineTestStates.Initial)); }
public void StartAndStop() { TestStateMachine stateMachine = new TestStateMachine(); stateMachine.Start(); Assert.Throws <StateMachineStoppedException>(() => stateMachine.GetState()); Assert.That(stateMachine.IsStarted(), Is.EqualTo(false)); stateMachine.StartMachine(); Assert.That(stateMachine.GetState(), Is.EqualTo(StateMachineTestStates.Initial)); Assert.That(stateMachine.IsStarted(), Is.EqualTo(true)); stateMachine.StopMachine(); Assert.Throws <StateMachineStoppedException>(() => stateMachine.GetState()); Assert.That(stateMachine.IsStarted(), Is.EqualTo(false)); }