Exemplo n.º 1
0
        public void TestCpuWorkerSignalStop()
        {
            CpuWorker worker = CreateCpuWorker();

            worker.Start();

            worker.SignalStop();
            Assert.AreEqual(worker.State, ExecutionState.Stopped);

            worker.SignalStop();
            Assert.AreEqual(worker.State, ExecutionState.Stopped);

            worker.Start();
            Assert.AreNotEqual(worker.State, ExecutionState.Stopped);

            worker.SignalPause();
            worker.SignalStop();
            Assert.AreEqual(worker.State, ExecutionState.Stopped);

            worker.Start();
            worker.SignalPause();
            worker.SignalResume();
            worker.SignalStop();
            Assert.AreEqual(worker.State, ExecutionState.Stopped);
        }
Exemplo n.º 2
0
        public void TestCpuWorkerStart()
        {
            CpuWorker worker = CreateCpuWorker();

            worker.Start();
            Assert.AreEqual(worker.State, ExecutionState.Running);

            worker.Start();
            Assert.AreEqual(worker.State, ExecutionState.Running);

            worker.SignalStop();
            Assert.AreNotEqual(worker.State, ExecutionState.Running);

            worker.Start();
            Assert.AreEqual(worker.State, ExecutionState.Running);

            worker.SignalPause();
            Assert.AreNotEqual(worker.State, ExecutionState.Running);

            Assert.Throws <InvalidOperationException>(() => worker.Start());
            Assert.AreNotEqual(worker.State, ExecutionState.Running);

            worker.SignalStop();
        }