Beispiel #1
0
        public void TrySetState_ReturnsTrue_WhenStateCannotTransition(SimulatorState from, SimulatorState to)
        {
            TestSimulator simulator = Substitute.ForPartsOf <TestSimulator>();

            while (simulator.State != from)
            {
                simulator.SetState(simulator.State + 1);
            }

            var result = simulator.TrySetState(to);

            result.ShouldBeTrue();
        }
Beispiel #2
0
        public void SetState_DoesNotThrow_WhenStateDoesNotChange(SimulatorState state)
        {
            TestSimulator simulator = Substitute.ForPartsOf <TestSimulator>();

            while (simulator.State != state)
            {
                simulator.SetState(simulator.State + 1);
            }

            Action action = () => simulator.SetState(state);

            action.ShouldNotThrow();
        }
Beispiel #3
0
        public void SetState_DoesNotThrow_WhenStateCanTransition(SimulatorState from, SimulatorState to)
        {
            TestSimulator simulator = Substitute.ForPartsOf <TestSimulator>();

            while (simulator.State != from)
            {
                simulator.SetState(simulator.State + 1);
            }

            Action action = () => simulator.SetState(to);

            action.ShouldNotThrow();
        }
Beispiel #4
0
        public void TrySetState_ReturnsTrue_WhenStateDoesNotChange(SimulatorState state)
        {
            TestSimulator simulator = Substitute.ForPartsOf <TestSimulator>();

            while (simulator.State != state)
            {
                simulator.SetState(simulator.State + 1);
            }

            var result = simulator.TrySetState(state);

            result.ShouldBeTrue();
        }
Beispiel #5
0
        public void SetState_Throws_WhenStateCannotTransition(SimulatorState from, SimulatorState to)
        {
            TestSimulator simulator = Substitute.ForPartsOf <TestSimulator>();

            while (simulator.State != from)
            {
                simulator.SetState(simulator.State + 1);
            }

            Action action = () => simulator.SetState(to);

            action.ShouldThrow <InvalidOperationException>()
            .Message.ShouldBe(SR.Format(SR.SimulatorStateCannotTransition, from, to));
        }