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(); }
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(); }
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)); }
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(); }
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(); }