public void ThrowsAnExceptionWhenStartingWhileInTheErrorState() { using var target = new StubProcessor(); target.SetState(ProcessorState.Error); Assert.Throws <RuntimeException>(() => target.Start()); }
public void ChangeToAnErrorStateWhenExceptionThrownDuringStart() { using var target = new StubProcessor(); target.SetupCallbacks(() => throw new Exception("This is a test exception")); Assert.Throws <Exception>(() => target.Start()); Assert.AreEqual(ProcessorState.Error, target.State); }
public void StoppingTwiceThrowsAnException() { using var target = new StubProcessor(); target.Start(); target.Stop(); Assert.Throws <RuntimeException>(() => target.Stop()); }
public void ThrowAnExceptionWhenTheProcessorIsAlreadyStarted() { using var target = new StubProcessor(); target.Start(); Assert.AreEqual(ProcessorState.Started, target.State); Assert.Throws <RuntimeException>(() => target.ExecuteGuardMustNotAlreadyBeStarted()); }
public void ThrowsAnExceptionWhenStartedAfterDisposed() { var target = new StubProcessor(); target.Dispose(); Assert.Throws <ObjectDisposedException>(() => target.Start()); }
public void ChangeTheProcessorStatesDuringStart() { var tested = false; using var target = new StubProcessor(); target.SetupCallbacks(() => { Assert.AreEqual(ProcessorState.Starting, target.State); tested = true; }); target.Start(); Assert.True(tested); Assert.AreEqual(ProcessorState.Started, target.State); }