public void RemoveTestRemoveExistingActiveThreads()
        {
            ThreadCollection tc = new ThreadCollection();
            GThreadMock      threadToRemove1 = new GThreadMock();
            GThreadMock      threadToRemove2 = new GThreadMock();
            GThreadMock      threadToRemove3 = new GThreadMock();
            GThreadMock      threadToRemove4 = new GThreadMock();

            tc.Add(threadToRemove1);
            tc.Add(threadToRemove2);
            tc.Add(threadToRemove3);
            tc.Add(threadToRemove4);

            Assert.AreEqual(4, tc.Count);

            threadToRemove1.SetState(ThreadState.Ready);
            threadToRemove2.SetState(ThreadState.Scheduled);
            threadToRemove3.SetState(ThreadState.Started);
            threadToRemove4.SetState(ThreadState.Unknown);

            tc.Remove(threadToRemove1);
            tc.Remove(threadToRemove2);
            tc.Remove(threadToRemove3);
            tc.Remove(threadToRemove4);

            // the thread should not have been removed
            // this remove function only allows the removal of Dead or Finished threads
            Assert.AreEqual(4, tc.Count);
        }
        public void RemoveTestRemoveExistingActiveThreads()
        {
            ThreadCollection tc = new ThreadCollection();
            GThreadMock threadToRemove1 = new GThreadMock();
            GThreadMock threadToRemove2 = new GThreadMock();
            GThreadMock threadToRemove3 = new GThreadMock();
            GThreadMock threadToRemove4 = new GThreadMock();

            tc.Add(threadToRemove1);
            tc.Add(threadToRemove2);
            tc.Add(threadToRemove3);
            tc.Add(threadToRemove4);

            Assert.AreEqual(4, tc.Count);

            threadToRemove1.SetState(ThreadState.Ready);
            threadToRemove2.SetState(ThreadState.Scheduled);
            threadToRemove3.SetState(ThreadState.Started);
            threadToRemove4.SetState(ThreadState.Unknown);

            tc.Remove(threadToRemove1);
            tc.Remove(threadToRemove2);
            tc.Remove(threadToRemove3);
            tc.Remove(threadToRemove4);

            // the thread should not have been removed
            // this remove function only allows the removal of Dead or Finished threads
            Assert.AreEqual(4, tc.Count);
        }
Example #3
0
        public void SetPriorityTestSimpleScenario()
        {
            int priority = 123;

            GThread thread = new GThreadMock();

            thread.Priority = priority;

            Assert.AreEqual(priority, thread.Priority);
        }
Example #4
0
        public void SetApplicationTestSimpleScenario()
        {
            GApplication application = new GApplication();

            GThread thread = new GThreadMock();

            thread.SetApplication(application);

            Assert.AreSame(application, thread.Application);
        }
Example #5
0
        public void SetPriorityTestSimpleScenario()
        {
            int priority = 123;

            GThread thread = new GThreadMock();

            thread.Priority = priority;

            Assert.AreEqual(priority, thread.Priority);
        }
Example #6
0
        public void SetApplicationTestSimpleScenario()
        {
            GApplication application = new GApplication();

            GThread thread = new GThreadMock();

            thread.SetApplication(application);

            Assert.AreSame(application, thread.Application);
        }
        public void RemoveTestEmptyCollection()
        {
            ThreadCollection tc = new ThreadCollection();
            GThreadMock threadToRemove = new GThreadMock();

            tc.Remove(threadToRemove);

            // if we get this far then there was no exception so we are happy
            Assert.IsTrue(true);
        }
        public void RemoveTestNullThreadToRemove()
        {
            ThreadCollection tc             = new ThreadCollection();
            GThreadMock      threadToRemove = null;

            tc.Remove(threadToRemove);

            // if we get this far then there was no exception so we are happy
            Assert.IsTrue(true);
        }
Example #9
0
        public void SetIdTestSimpleScenario()
        {
            Int32 threadId = 324;

            GThread thread = new GThreadMock();

            thread.SetId(threadId);

            Assert.AreEqual(threadId, thread.Id);
        }
Example #10
0
        public void SetIdTestSimpleScenario()
        {
            Int32 threadId = 324;

            GThread thread = new GThreadMock();

            thread.SetId(threadId);

            Assert.AreEqual(threadId, thread.Id);
        }
Example #11
0
        public void SetWorkingDirectoryTestSimpleScenario()
        {
            string workingDirectory = @"C:\";

            GThreadMock threadFiller = new GThreadMock();
            GThread     thread       = threadFiller;

            thread.SetWorkingDirectory(workingDirectory);

            Assert.AreEqual(workingDirectory, threadFiller.GetWorkingDirectory());
        }
Example #12
0
        public void SetStateTestSimpleScenario()
        {
            GApplicationMock application = new GApplicationMock();

            GThreadMock thread = new GThreadMock();

            // NOTE: In fact, this exercises the State implementation found in GThreadMock
            thread.SetState(ThreadState.Scheduled);

            Assert.AreEqual(ThreadState.Scheduled, thread.State);
        }
Example #13
0
        public void SetWorkingDirectoryTestSimpleScenario()
        {
            string workingDirectory = @"C:\";

            GThreadMock threadFiller = new GThreadMock();
            GThread thread = threadFiller;

            thread.SetWorkingDirectory(workingDirectory);

            Assert.AreEqual(workingDirectory, threadFiller.GetWorkingDirectory());
        }
Example #14
0
        public void SetStateTestSimpleScenario()
        {
            GApplicationMock application = new GApplicationMock();

            GThreadMock thread = new GThreadMock();

            // NOTE: In fact, this exercises the State implementation found in GThreadMock
            thread.SetState(ThreadState.Scheduled);

            Assert.AreEqual(ThreadState.Scheduled, thread.State);
        }
        public void RemoveTestRemoveExistingDeadOrFinishedThread()
        {
            ThreadCollection tc = new ThreadCollection();
            GThreadMock      threadToRemove1 = new GThreadMock();
            GThreadMock      threadToRemove2 = new GThreadMock();

            tc.Add(threadToRemove1);
            tc.Add(threadToRemove2);

            Assert.AreEqual(2, tc.Count);

            threadToRemove1.SetState(ThreadState.Dead);
            threadToRemove2.SetState(ThreadState.Finished);

            tc.Remove(threadToRemove1);

            // the thread should have been removed
            Assert.AreEqual(1, tc.Count);

            tc.Remove(threadToRemove2);

            // the thread should have been removed
            Assert.AreEqual(0, tc.Count);
        }
        public void RemoveTestRemoveExistingDeadOrFinishedThread()
        {
            ThreadCollection tc = new ThreadCollection();
            GThreadMock threadToRemove1 = new GThreadMock();
            GThreadMock threadToRemove2 = new GThreadMock();

            tc.Add(threadToRemove1);
            tc.Add(threadToRemove2);

            Assert.AreEqual(2, tc.Count);

            threadToRemove1.SetState(ThreadState.Dead);
            threadToRemove2.SetState(ThreadState.Finished);

            tc.Remove(threadToRemove1);

            // the thread should have been removed
            Assert.AreEqual(1, tc.Count);

            tc.Remove(threadToRemove2);

            // the thread should have been removed
            Assert.AreEqual(0, tc.Count);
        }