Ejemplo n.º 1
0
        public void TestIsBackground1()
        {
            if (is_win32 && is_mono)
            {
                Assert.Fail("This test fails on mono on Win32. Our runtime should be fixed.");
            }

            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                TestThread.Start();
                TestUtil.WaitForAlive(TestThread, "wait9");
                bool state = TestThread.IsBackground;
                Assert.IsFalse(state, "#51 IsBackground not set at the default state: ");
            } finally {
                TestThread.Abort();
            }
        }
Ejemplo n.º 2
0
        [Category("NotWorking")]         // this is a MonoTODO -> no support for Priority
        public void TestPriority2()
        {
            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                Assert.AreEqual(ThreadPriority.Normal, TestThread.Priority, "#42 Incorrect Priority in New thread: ");
                TestThread.Start();
                TestUtil.WaitForAliveOrStop(TestThread, "wait8");
                Assert.AreEqual(ThreadPriority.Normal, TestThread.Priority, "#43 Incorrect Priority in Started thread: ");
            } finally {
#if MONO_FEATURE_THREAD_ABORT
                TestThread.Abort();
#else
                TestThread.Interrupt();
#endif
            }
            Assert.AreEqual(ThreadPriority.Normal, TestThread.Priority, "#44 Incorrect Priority in Aborted thread: ");
        }
Ejemplo n.º 3
0
        public void TestApartmentState()
        {
            if (is_win32 && is_mono)
            {
                Assert.Fail("This test fails on mono on win32. Our runtime should be fixed.");
            }

            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            Assert.AreEqual(ApartmentState.Unknown, TestThread.ApartmentState, "#1");
            TestThread.Start();
            TestUtil.WaitForAlive(TestThread, "wait5");
#if NET_2_0
            Assert.AreEqual(ApartmentState.MTA, TestThread.ApartmentState, "#2");
#else
            Assert.AreEqual(ApartmentState.Unknown, TestThread.ApartmentState, "#3");
#endif
            TestThread.Abort();
        }
Ejemplo n.º 4
0
        [Category("NotWorking")]          // setting the priority of a Thread before it is started isn't implemented in Mono yet
        public void TestPriority1()
        {
            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                TestThread.Priority = ThreadPriority.BelowNormal;
                ThreadPriority before = TestThread.Priority;
                Assert.AreEqual(ThreadPriority.BelowNormal, before, "#40 Unexpected priority before thread start: ");
                TestThread.Start();
                TestUtil.WaitForAlive(TestThread, "wait7");
                ThreadPriority after = TestThread.Priority;
                Assert.AreEqual(before, after, "#41 Unexpected Priority Change: ");
            } finally {
#if MONO_FEATURE_THREAD_ABORT
                TestThread.Abort();
#else
                TestThread.Interrupt();
#endif
            }
        }
Ejemplo n.º 5
0
        public void TestName()
        {
            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                TestThread.Start();
                TestUtil.WaitForAlive(TestThread, "wait10");
                string name = TestThread.Name;
                Assert.IsNull(name, "#61 Name set when mustn't be set: ");
                string newname = "Testing....";
                TestThread.Name = newname;
                Assert.AreEqual(newname, TestThread.Name, "#62 Name not set when must be set: ");
            } finally {
#if MONO_FEATURE_THREAD_ABORT
                TestThread.Abort();
#else
                TestThread.Interrupt();
#endif
            }
        }
Ejemplo n.º 6
0
        public void TestIsBackground2()
        {
            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            TestThread.IsBackground = true;
            try {
                TestThread.Start();
            } finally {
                TestThread.Abort();
            }

            if (TestThread.IsAlive)
            {
                try {
                    Assert.IsTrue(TestThread.IsBackground, "#52 Is Background Changed to Start ");
                } catch (ThreadStateException) {
                    // Ignore if thread died meantime
                }
            }
        }
Ejemplo n.º 7
0
        public void TestPriority1()
        {
            if (is_win32 && is_mono)
            {
                Assert.Fail("This test fails on mono on Win32. Our runtime should be fixed.");
            }

            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                TestThread.Priority = ThreadPriority.BelowNormal;
                ThreadPriority after = TestThread.Priority;
                TestThread.Start();
                TestUtil.WaitForAlive(TestThread, "wait7");
                ThreadPriority before = TestThread.Priority;
                Assert.AreEqual(before, after, "#41 Unexpected Priority Change: ");
            } finally {
                TestThread.Abort();
            }
        }
Ejemplo n.º 8
0
        [Category("NotDotNet")]          // it hangs.
        public void TestStart()
        {
            {
                C1Test test1      = new C1Test();
                Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
                TestThread.Start();
                TestThread.Join();
                Assert.AreEqual(10, test1.cnt, "#1");
            }
            {
                C2Test test1      = new C2Test();
                Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
                TestThread.Start();
#if MONO_FEATURE_THREAD_ABORT
                TestThread.Abort();
#else
                TestThread.Interrupt();
#endif
                try {
                    TestThread.Start();
                    Assert.Fail("#2");
                } catch (ThreadStateException) {
                }
            }
            {
                C2Test test1      = new C2Test();
                Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
                TestThread.Start();
                while (!test1.run)
                {
                }
                bool started = (TestThread.ThreadState == ThreadState.Running);
                Assert.AreEqual(started, test1.run, "#15 Thread Is not in the correct state: ");
#if MONO_FEATURE_THREAD_ABORT
                TestThread.Abort();
#else
                TestThread.Interrupt();
#endif
            }
        }
Ejemplo n.º 9
0
        public void TestName()
        {
            if (is_win32 && is_mono)
            {
                Assert.Fail("This test fails on mono on Win32. Our runtime should be fixed.");
            }

            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                TestThread.Start();
                TestUtil.WaitForAlive(TestThread, "wait10");
                string name = TestThread.Name;
                Assert.IsNull(name, "#61 Name set when mustn't be set: ");
                string newname = "Testing....";
                TestThread.Name = newname;
                Assert.AreEqual(newname, TestThread.Name, "#62 Name not set when must be set: ");
            } finally {
                TestThread.Abort();
            }
        }
Ejemplo n.º 10
0
 [Category("NotDotNet")] // it hangs.
 public void TestStart()
 {
     if (is_win32 && is_mono)
     {
         Assert.Fail("This test fails on Win32. The test should be fixed.");
     }
     {
         C1Test test1      = new C1Test();
         Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
         TestThread.Start();
         TestThread.Join();
         Assert.AreEqual(10, test1.cnt, "#1");
     }
     {
         C2Test test1      = new C2Test();
         Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
         TestThread.Start();
         TestThread.Abort();
         try
         {
             TestThread.Start();
             Assert.Fail("#2");
         }
         catch (ThreadStateException)
         {
         }
     }
     {
         C2Test test1      = new C2Test();
         Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
         TestThread.Start();
         while (!test1.run)
         {
         }
         bool started = (TestThread.ThreadState == ThreadState.Running);
         Assert.AreEqual(started, test1.run, "#15 Thread Is not in the correct state: ");
         TestThread.Abort();
     }
 }
Ejemplo n.º 11
0
        [Category("NotWorking")]          // this is a MonoTODO -> no support for Priority
        public void TestPriority3()
        {
            C2Test test1      = new C2Test();
            Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));

            try {
                TestThread.Start();
                TestThread.Priority = ThreadPriority.Lowest;
                Assert.AreEqual(ThreadPriority.Lowest, TestThread.Priority, "#45A Incorrect Priority:");
                TestThread.Priority = ThreadPriority.BelowNormal;
                Assert.AreEqual(ThreadPriority.BelowNormal, TestThread.Priority, "#45B Incorrect Priority:");
                TestThread.Priority = ThreadPriority.Normal;
                Assert.AreEqual(ThreadPriority.Normal, TestThread.Priority, "#45C Incorrect Priority:");
                TestThread.Priority = ThreadPriority.AboveNormal;
                Assert.AreEqual(ThreadPriority.AboveNormal, TestThread.Priority, "#45D Incorrect Priority:");
                TestThread.Priority = ThreadPriority.Highest;
                Assert.AreEqual(ThreadPriority.Highest, TestThread.Priority, "#45E Incorrect Priority:");
            }
            finally {
                TestThread.Abort();
            }
        }
Ejemplo n.º 12
0
		public void TestApartmentState ()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			Assert.AreEqual (ApartmentState.Unknown, TestThread.ApartmentState, "#1");
			TestThread.Start();
			TestUtil.WaitForAlive (TestThread, "wait5");
			Assert.AreEqual (ApartmentState.MTA, TestThread.ApartmentState, "#2");
#if MONO_FEATURE_THREAD_ABORT
			TestThread.Abort();
#else
			TestThread.Interrupt ();
#endif
		}
Ejemplo n.º 13
0
		[Category ("NotWorking")] // setting the priority of a Thread before it is started isn't implemented in Mono yet
		public void TestPriority1()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Priority=ThreadPriority.BelowNormal;
				ThreadPriority before = TestThread.Priority;
				Assert.AreEqual (ThreadPriority.BelowNormal, before, "#40 Unexpected priority before thread start: ");
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait7");
				ThreadPriority after = TestThread.Priority;
				Assert.AreEqual (before, after, "#41 Unexpected Priority Change: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}
Ejemplo n.º 14
0
		public void TestIsBackground1 ()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait9");
				bool state = TestThread.IsBackground;
				Assert.IsFalse (state, "#51 IsBackground not set at the default state: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}
Ejemplo n.º 15
0
		public void TestThreadState ()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on mono on Win32. Our runtime should be fixed.");

			//TODO: Test The rest of the possible transitions
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			Assert.AreEqual (ThreadState.Unstarted, TestThread.ThreadState, "#101 Wrong Thread State");
			try {
				TestThread.Start();
				//while(!TestThread.IsAlive); //In the MS Documentation this is not necessary
											  //but in the MS SDK it is
				Assert.IsTrue (TestThread.ThreadState == ThreadState.Running || (TestThread.ThreadState & ThreadState.Unstarted) != 0,
					"#102 Wrong Thread State: " + TestThread.ThreadState.ToString ());
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
			
			TestUtil.WaitForNotAlive (TestThread, "wait12");
			// Docs say state will be Stopped, but Aborted happens sometimes (?)
			Assert.IsTrue ((ThreadState.Stopped & TestThread.ThreadState) != 0 || (ThreadState.Aborted & TestThread.ThreadState) != 0,
				"#103 Wrong Thread State: " + TestThread.ThreadState.ToString ());
		}
Ejemplo n.º 16
0
		public void TestName()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on mono on Win32. Our runtime should be fixed.");

			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait10");
				string name = TestThread.Name;
				Assert.IsNull (name, "#61 Name set when mustn't be set: ");
				string newname = "Testing....";
				TestThread.Name = newname;
				Assert.AreEqual (newname, TestThread.Name, "#62 Name not set when must be set: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}
Ejemplo n.º 17
0
		public void TestIsBackground2 ()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.IsBackground = true;
			try {
				TestThread.Start();
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
			
			if (TestThread.IsAlive) {
				try {
					Assert.IsTrue (TestThread.IsBackground, "#52 Is Background Changed to Start ");
				} catch (ThreadStateException) {
					// Ignore if thread died meantime
				}
			}
		}
Ejemplo n.º 18
0
		public void TestName()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait10");
				string name = TestThread.Name;
				Assert.IsNull (name, "#61 Name set when mustn't be set: ");
				string newname = "Testing....";
				TestThread.Name = newname;
				Assert.AreEqual (newname, TestThread.Name, "#62 Name not set when must be set: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}
Ejemplo n.º 19
0
		public void TestName()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait10");
				string name = TestThread.Name;
				AssertEquals("#61 Name set when mustn't be set: ", name, (string)null);
				string newname = "Testing....";
				TestThread.Name = newname;
				AssertEquals("#62 Name not set when must be set: ",TestThread.Name,newname);
			}
			finally {
				TestThread.Abort();
			}
		}
Ejemplo n.º 20
0
		public void TestIsBackground1()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait9");
				bool state = TestThread.IsBackground;
				Assert("#51 IsBackground not set at the default state: ",!(state));
			}
			finally {
				TestThread.Abort();
			}
		}
Ejemplo n.º 21
0
		[Category("NotWorking")] // this is a MonoTODO -> no support for Priority
		public void TestPriority2()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				AssertEquals("#42 Incorrect Priority in New thread: ",ThreadPriority.Normal, TestThread.Priority);
				TestThread.Start();
				TestUtil.WaitForAliveOrStop (TestThread, "wait8");
				AssertEquals("#43 Incorrect Priority in Started thread: ",ThreadPriority.Normal, TestThread.Priority);
			}
			finally {
				TestThread.Abort();
			}
			AssertEquals("#44 Incorrect Priority in Aborted thread: ",ThreadPriority.Normal, TestThread.Priority);
		}
Ejemplo n.º 22
0
		public void TestPriority1()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Priority=ThreadPriority.BelowNormal;
				ThreadPriority after = TestThread.Priority;
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait7");
				ThreadPriority before = TestThread.Priority;
				AssertEquals("#41 Unexpected Priority Change: ",before,after);
			}
			finally {
				TestThread.Abort();
			}
		}
Ejemplo n.º 23
0
		public void TestStart()
		{
		{
			C1Test test1 = new C1Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try
			{
				TestThread.Start();
			}
			catch (Exception e)
			{
				Fail ("#12 Unexpected Exception Thrown: " + e.ToString ());
			}
			TestThread.Join();
			AssertEquals("#13 Thread Not started: ", 10,test1.cnt);
		}
		{
			bool errorThrown = false;
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.Start();
			TestThread.Abort();
			try
			{
				TestThread.Start();
			}
			catch(ThreadStateException)
			{
				errorThrown = true;
			}
			Assert ("#14 no ThreadStateException trown", errorThrown);
		}
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.Start();
			while(!test1.run);
			bool started = (TestThread.ThreadState == ThreadState.Running);
			AssertEquals("#15 Thread Is not in the correct state: ", started , test1.run);	
			TestThread.Abort();
		}
		}
Ejemplo n.º 24
0
		public void TestPriority1()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on mono on Win32. Our runtime should be fixed.");

			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Priority=ThreadPriority.BelowNormal;
				ThreadPriority after = TestThread.Priority;
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait7");
				ThreadPriority before = TestThread.Priority;
				Assert.AreEqual (before, after, "#41 Unexpected Priority Change: ");
			} finally {
				TestThread.Abort();
			}
		}
Ejemplo n.º 25
0
		public void TestIsBackground2 ()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.IsBackground = true;
			try {
				TestThread.Start();
			} finally {
				TestThread.Abort();
			}
			
			if (TestThread.IsAlive)
				Assert.IsTrue (TestThread.IsBackground, "#52 Is Background Changed to Start ");
		}
Ejemplo n.º 26
0
		[Category ("NotDotNet")] // it hangs.
		public void TestStart()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on Win32. The test should be fixed.");
		{
			C1Test test1 = new C1Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.Start();
			TestThread.Join();
			Assert.AreEqual (10, test1.cnt, "#1");
		}
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.Start();
#if MONO_FEATURE_THREAD_ABORT
			TestThread.Abort();
#else
			TestThread.Interrupt ();
#endif
			try {
				TestThread.Start();
				Assert.Fail ("#2");
			} catch (ThreadStateException) {
			}
		}
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.Start();
			while (!test1.run) {
			}
			bool started = (TestThread.ThreadState == ThreadState.Running);
			Assert.AreEqual (started, test1.run, "#15 Thread Is not in the correct state: ");
#if MONO_FEATURE_THREAD_ABORT
			TestThread.Abort();
#else
			TestThread.Interrupt ();
#endif
		}
		}
Ejemplo n.º 27
0
		public void TestIsBackground2 ()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.IsBackground = true;
			try {
				TestThread.Start();
			} finally {
				TestThread.Abort();
			}
			
			if (TestThread.IsAlive) {
				try {
					Assert.IsTrue (TestThread.IsBackground, "#52 Is Background Changed to Start ");
				} catch (ThreadStateException) {
					// Ignore if thread died meantime
				}
			}
		}
Ejemplo n.º 28
0
		public void TestApartmentState()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			ApartmentState before = TestThread.ApartmentState;
			TestThread.Start();
			TestUtil.WaitForAlive (TestThread, "wait6");
			ApartmentState after = TestThread.ApartmentState;
			TestThread.Abort();
			AssertEquals("#31 Apartment State Changed when not needed: ",before,after);
		}
Ejemplo n.º 29
0
		public void TestApartmentState ()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on mono on win32. Our runtime should be fixed.");

			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			Assert.AreEqual (ApartmentState.Unknown, TestThread.ApartmentState, "#1");
			TestThread.Start();
			TestUtil.WaitForAlive (TestThread, "wait5");
			Assert.AreEqual (ApartmentState.MTA, TestThread.ApartmentState, "#2");
#if MONO_FEATURE_THREAD_ABORT
			TestThread.Abort();
#else
			TestThread.Interrupt ();
#endif
		}
Ejemplo n.º 30
0
		public void AbortUnstarted ()
		{
			C2Test test1 = new C2Test();
			Thread th = new Thread (new ThreadStart (test1.TestMethod));
			th.Abort ();
			th.Start ();
		}
Ejemplo n.º 31
0
		[Category ("NotWorking")] // setting the priority of a Thread before it is started isn't implemented in Mono yet
		public void TestPriority1()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on mono on Win32. Our runtime should be fixed.");

			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Priority=ThreadPriority.BelowNormal;
				ThreadPriority before = TestThread.Priority;
				Assert.AreEqual (ThreadPriority.BelowNormal, before, "#40 Unexpected priority before thread start: ");
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait7");
				ThreadPriority after = TestThread.Priority;
				Assert.AreEqual (before, after, "#41 Unexpected Priority Change: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}
Ejemplo n.º 32
0
		[Category("NotWorking")] // this is a MonoTODO -> no support for Priority
		public void TestPriority3()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestThread.Priority = ThreadPriority.Lowest;
				AssertEquals("#45A Incorrect Priority:",ThreadPriority.Lowest,TestThread.Priority);
				TestThread.Priority = ThreadPriority.BelowNormal;
				AssertEquals("#45B Incorrect Priority:",ThreadPriority.BelowNormal,TestThread.Priority);
				TestThread.Priority = ThreadPriority.Normal;
				AssertEquals("#45C Incorrect Priority:",ThreadPriority.Normal,TestThread.Priority);
				TestThread.Priority = ThreadPriority.AboveNormal;
				AssertEquals("#45D Incorrect Priority:",ThreadPriority.AboveNormal,TestThread.Priority);
				TestThread.Priority = ThreadPriority.Highest;
				AssertEquals("#45E Incorrect Priority:",ThreadPriority.Highest,TestThread.Priority);
			}
			finally {
				TestThread.Abort();
			}
		}
Ejemplo n.º 33
0
		[Category ("NotWorking")] // this is a MonoTODO -> no support for Priority
		public void TestPriority2()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				Assert.AreEqual (ThreadPriority.Normal, TestThread.Priority, "#42 Incorrect Priority in New thread: ");
				TestThread.Start();
				TestUtil.WaitForAliveOrStop (TestThread, "wait8");
				Assert.AreEqual (ThreadPriority.Normal, TestThread.Priority, "#43 Incorrect Priority in Started thread: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
			Assert.AreEqual (ThreadPriority.Normal, TestThread.Priority, "#44 Incorrect Priority in Aborted thread: ");
		}
Ejemplo n.º 34
0
		public void TestIsBackground2()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			TestThread.IsBackground = true;
			try {
				TestThread.Start();
			}
			finally {
				TestThread.Abort();
			}
			Assert("#52 Is Background Changed ot Start ",TestThread.IsBackground);
		}
Ejemplo n.º 35
0
		[Category ("NotWorking")] // this is a MonoTODO -> no support for Priority
		public void TestPriority3()
		{
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestThread.Priority = ThreadPriority.Lowest;
				Assert.AreEqual (ThreadPriority.Lowest, TestThread.Priority, "#45A Incorrect Priority:");
				TestThread.Priority = ThreadPriority.BelowNormal;
				Assert.AreEqual (ThreadPriority.BelowNormal, TestThread.Priority, "#45B Incorrect Priority:");
				TestThread.Priority = ThreadPriority.Normal;
				Assert.AreEqual (ThreadPriority.Normal, TestThread.Priority, "#45C Incorrect Priority:");
				TestThread.Priority = ThreadPriority.AboveNormal;
				Assert.AreEqual (ThreadPriority.AboveNormal, TestThread.Priority, "#45D Incorrect Priority:");
				TestThread.Priority = ThreadPriority.Highest;
				Assert.AreEqual (ThreadPriority.Highest, TestThread.Priority, "#45E Incorrect Priority:");
			}
			finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}
Ejemplo n.º 36
0
		public void TestThreadState()
		{
			//TODO: Test The rest of the possible transitions
			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			AssertEquals("#101 Wrong Thread State",ThreadState.Unstarted,TestThread.ThreadState);
			try {
				TestThread.Start();
				//while(!TestThread.IsAlive); //In the MS Documentation this is not necessary
											  //but in the MS SDK it is
				Assert("#102 Wrong Thread State: " + TestThread.ThreadState.ToString(), TestThread.ThreadState == ThreadState.Running || (TestThread.ThreadState & ThreadState.Unstarted) != 0);
			}
			finally {
				TestThread.Abort();
			}
			
			TestUtil.WaitForNotAlive (TestThread, "wait12");
			// Docs say state will be Stopped, but Aborted happens sometimes (?)
			Assert("#103 Wrong Thread State: " + TestThread.ThreadState.ToString(), (ThreadState.Stopped & TestThread.ThreadState) != 0 
				|| (ThreadState.Aborted & TestThread.ThreadState) != 0);
		} 
Ejemplo n.º 37
0
		public void TestIsBackground1 ()
		{
			if (is_win32 && is_mono)
				Assert.Fail ("This test fails on mono on Win32. Our runtime should be fixed.");

			C2Test test1 = new C2Test();
			Thread TestThread = new Thread(new ThreadStart(test1.TestMethod));
			try {
				TestThread.Start();
				TestUtil.WaitForAlive (TestThread, "wait9");
				bool state = TestThread.IsBackground;
				Assert.IsFalse (state, "#51 IsBackground not set at the default state: ");
			} finally {
#if MONO_FEATURE_THREAD_ABORT
				TestThread.Abort();
#else
				TestThread.Interrupt ();
#endif
			}
		}