public void StoppingTwiceThrowsAnException() { using var target = new StubProcessor(); target.Start(); target.Stop(); Assert.Throws <RuntimeException>(() => target.Stop()); }
public void ThrowsAnExceptionWhenStoppingWhileInTheErrorState() { using var target = new StubProcessor(); target.SetState(ProcessorState.Error); Assert.Throws <RuntimeException>(() => target.Stop()); }
public void ThrowsAnExceptionWhenStoppedAfterDisposed() { var target = new StubProcessor(); target.Dispose(); Assert.Throws <ObjectDisposedException>(() => target.Stop()); }
public void ChangeToAnErrorStateWhenExceptionThrownDuringStop() { using var target = new StubProcessor(); target.SetupCallbacks(onStopCallback: () => throw new Exception("This is a test exception")); target.Start(); Assert.Throws <Exception>(() => target.Stop()); Assert.AreEqual(ProcessorState.Error, target.State); }
public void ThrowAnExceptionWhenTheProcessorIsAlreadyStopped() { using var target = new StubProcessor(); target.Start(); Assert.AreEqual(ProcessorState.Started, target.State); target.Stop(); Assert.AreEqual(ProcessorState.Stopped, target.State); Assert.Throws <RuntimeException>(() => target.ExecuteGuardMustNotAlreadyBeStopped()); }
public void ChangeTheProcessorStatesDuringStop() { var tested = false; using var target = new StubProcessor(); target.SetupCallbacks(onStopCallback: () => { Assert.AreEqual(ProcessorState.Stopping, target.State); tested = true; }); target.Start(); target.Stop(); Assert.True(tested); Assert.AreEqual(ProcessorState.Stopped, target.State); }