Ejemplo n.º 1
0
    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));
    }
Ejemplo n.º 2
0
    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));
    }