Example #1
0
        public void StoppingTwiceThrowsAnException()
        {
            using var target = new StubProcessor();
            target.Start();
            target.Stop();

            Assert.Throws <RuntimeException>(() => target.Stop());
        }
Example #2
0
        public void ThrowsAnExceptionWhenStoppingWhileInTheErrorState()
        {
            using var target = new StubProcessor();
            target.SetState(ProcessorState.Error);

            Assert.Throws <RuntimeException>(() => target.Stop());
        }
Example #3
0
        public void ThrowsAnExceptionWhenStoppedAfterDisposed()
        {
            var target = new StubProcessor();

            target.Dispose();

            Assert.Throws <ObjectDisposedException>(() => target.Stop());
        }
Example #4
0
        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);
        }
Example #5
0
        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());
        }
Example #6
0
        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);
        }