Ejemplo n.º 1
0
        public void StoppingTwiceThrowsAnException()
        {
            using var target = new StubProcessor();
            target.Start();
            target.Stop();

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

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

            target.Dispose();

            Assert.Throws <ObjectDisposedException>(() => target.Stop());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }