Example #1
0
        public void ThrowsAnExceptionWhenStartingWhileInTheErrorState()
        {
            using var target = new StubProcessor();
            target.SetState(ProcessorState.Error);

            Assert.Throws <RuntimeException>(() => target.Start());
        }
Example #2
0
        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);
        }
Example #3
0
        public void StoppingTwiceThrowsAnException()
        {
            using var target = new StubProcessor();
            target.Start();
            target.Stop();

            Assert.Throws <RuntimeException>(() => target.Stop());
        }
Example #4
0
        public void ThrowAnExceptionWhenTheProcessorIsAlreadyStarted()
        {
            using var target = new StubProcessor();
            target.Start();

            Assert.AreEqual(ProcessorState.Started, target.State);
            Assert.Throws <RuntimeException>(() => target.ExecuteGuardMustNotAlreadyBeStarted());
        }
Example #5
0
        public void ThrowsAnExceptionWhenStartedAfterDisposed()
        {
            var target = new StubProcessor();

            target.Dispose();

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