コード例 #1
0
        public void AddThread_IfNoThreadRunning_ThreadIsStarted()
        {
            var testThread = Substitute.For <ISynchronizedThread>();

            testThread.ThreadState.Returns(ThreadState.Unstarted);

            var threadPool = new ThreadPool();

            threadPool.AddThread(testThread);

            testThread.Received().Start();
        }
コード例 #2
0
        public void AddThread_IfThreadIsAlreadyRunning_EnqueueIncomingThreads()
        {
            var testThread1 = Substitute.For <ISynchronizedThread>();

            testThread1.ThreadState.Returns(ThreadState.Unstarted);
            var testThread2 = Substitute.For <ISynchronizedThread>();

            testThread2.ThreadState.Returns(ThreadState.Unstarted);
            var threadPool = new ThreadPool();

            threadPool.AddThread(testThread1);
            threadPool.AddThread(testThread2);

            testThread2.DidNotReceive().Start();
        }