[Test] // bug #325566 public void GetHashCodeTest() { C1Test test1 = new C1Test(); Thread tA = new Thread(new ThreadStart(test1.TestMethod)); int hA1 = tA.GetHashCode(); Assert.IsTrue(hA1 > 0, "#A1"); tA.Start(); int hA2 = tA.GetHashCode(); Assert.AreEqual(hA1, hA2, "#A2"); tA.Join(); int hA3 = tA.GetHashCode(); Assert.AreEqual(hA1, hA3, "#A3"); Assert.AreEqual(hA1, tA.ManagedThreadId, "#A4"); test1 = new C1Test(); Thread tB = new Thread(new ThreadStart(test1.TestMethod)); int hB1 = tB.GetHashCode(); Assert.IsTrue(hB1 > 0, "#B1"); tB.Start(); int hB2 = tB.GetHashCode(); Assert.AreEqual(hB1, hB2, "#B2"); tB.Join(); int hB3 = tB.GetHashCode(); Assert.AreEqual(hB1, hB3, "#B3"); Assert.AreEqual(hB1, tB.ManagedThreadId, "#B4"); Assert.IsFalse(hA2 == hB2, "#B5"); }
[Test] // bug #82700 public void ManagedThreadId() { C1Test test1 = new C1Test(); Thread t1 = new Thread(new ThreadStart(test1.TestMethod)); int mtA1 = t1.ManagedThreadId; t1.Start(); int mtA2 = t1.ManagedThreadId; t1.Join(); int mtA3 = t1.ManagedThreadId; Assert.AreEqual(mtA1, mtA2, "#A1"); Assert.AreEqual(mtA2, mtA3, "#A2"); test1 = new C1Test(); Thread t2 = new Thread(new ThreadStart(test1.TestMethod)); int mtB1 = t2.ManagedThreadId; t2.Start(); int mtB2 = t2.ManagedThreadId; t2.Join(); int mtB3 = t2.ManagedThreadId; Assert.AreEqual(mtB1, mtB2, "#B1"); Assert.AreEqual(mtB2, mtB3, "#B2"); Assert.IsFalse(mtB1 == mtA1, "#B3"); }
public C4Test() { T1ON = false; T2ON = false; class1 = new C1Test(); class2 = new C1Test(); thread1 = new Thread(new ThreadStart(class1.TestMethod)); thread2 = new Thread(new ThreadStart(class2.TestMethod)); }
public void TestCtor1() { C1Test test1 = new C1Test(); Thread t = new Thread(new ThreadStart(test1.TestMethod)); Assert.IsTrue(t.CurrentCulture.IsReadOnly, "CurrentCulture.IsReadOnly"); Assert.IsFalse(t.IsAlive, "IsAlive"); Assert.IsFalse(t.IsBackground, "IsBackground"); Assert.IsNull(t.Name, "Name"); Assert.AreEqual(ThreadState.Unstarted, t.ThreadState, "ThreadState"); }
public void TestJoin1() { C1Test test1 = new C1Test(); C1Test test2 = new C1Test(); Thread thread1 = new Thread(new ThreadStart(test1.TestMethod)); Thread thread2 = new Thread(new ThreadStart(test1.TestMethod2)); try { thread1.Start(); thread2.Start(); thread2.Join(); } finally { thread1.Abort(); thread2.Abort(); } }
[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 } }
public void TestJoin1() { C1Test test1 = new C1Test(); C1Test test2 = new C1Test(); Thread thread1 = new Thread(new ThreadStart(test1.TestMethod)); Thread thread2 = new Thread(new ThreadStart(test1.TestMethod2)); try { thread1.Start(); thread2.Start(); thread2.Join(); } finally { #if MONO_FEATURE_THREAD_ABORT thread1.Abort(); thread2.Abort(); #else thread1.Interrupt(); thread2.Interrupt(); #endif } }
public C3Test() { sub_class = new C1Test(); sub_thread = new Thread(new ThreadStart(sub_class.TestMethod)); }
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(); } }
[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 } }
[Test] // bug #82700 public void ManagedThreadId () { C1Test test1 = new C1Test (); Thread t1 = new Thread (new ThreadStart (test1.TestMethod)); int mtA1 = t1.ManagedThreadId; t1.Start (); int mtA2 = t1.ManagedThreadId; t1.Join (); int mtA3 = t1.ManagedThreadId; Assert.AreEqual (mtA1, mtA2, "#A1"); Assert.AreEqual (mtA2, mtA3, "#A2"); test1 = new C1Test (); Thread t2 = new Thread (new ThreadStart (test1.TestMethod)); int mtB1 = t2.ManagedThreadId; t2.Start (); int mtB2 = t2.ManagedThreadId; t2.Join (); int mtB3 = t2.ManagedThreadId; Assert.AreEqual (mtB1, mtB2, "#B1"); Assert.AreEqual (mtB2, mtB3, "#B2"); Assert.IsFalse (mtB1 == mtA1, "#B3"); }
[Test] // bug #325566 public void GetHashCodeTest () { C1Test test1 = new C1Test (); Thread tA = new Thread (new ThreadStart (test1.TestMethod)); int hA1 = tA.GetHashCode (); Assert.IsTrue (hA1 > 0, "#A1"); tA.Start (); int hA2 = tA.GetHashCode (); Assert.AreEqual (hA1, hA2, "#A2"); tA.Join (); int hA3 = tA.GetHashCode (); Assert.AreEqual (hA1, hA3, "#A3"); Assert.AreEqual (hA1, tA.ManagedThreadId, "#A4"); test1 = new C1Test (); Thread tB = new Thread (new ThreadStart (test1.TestMethod)); int hB1 = tB.GetHashCode (); Assert.IsTrue (hB1 > 0, "#B1"); tB.Start (); int hB2 = tB.GetHashCode (); Assert.AreEqual (hB1, hB2, "#B2"); tB.Join (); int hB3 = tB.GetHashCode (); Assert.AreEqual (hB1, hB3, "#B3"); Assert.AreEqual (hB1, tB.ManagedThreadId, "#B4"); Assert.IsFalse (hA2 == hB2, "#B5"); }
public void TestCtor1() { C1Test test1 = new C1Test(); Thread t = new Thread (new ThreadStart (test1.TestMethod)); Assert.IsTrue (t.CurrentCulture.IsReadOnly, "CurrentCulture.IsReadOnly"); Assert.IsFalse (t.IsAlive, "IsAlive"); Assert.IsFalse (t.IsBackground, "IsBackground"); Assert.IsNull (t.Name, "Name"); Assert.AreEqual (ThreadState.Unstarted, t.ThreadState, "ThreadState"); }
public void TestJoin1() { C1Test test1 = new C1Test(); C1Test test2 = new C1Test(); Thread thread1 = new Thread(new ThreadStart(test1.TestMethod)); Thread thread2 = new Thread(new ThreadStart(test1.TestMethod2)); try { thread1.Start(); thread2.Start(); thread2.Join(); } finally { #if MONO_FEATURE_THREAD_ABORT thread1.Abort(); thread2.Abort(); #else thread1.Interrupt (); thread2.Interrupt (); #endif } }
public void TestCtor1() { C1Test test1 = new C1Test(); try { Thread TestThread = new Thread(new ThreadStart(test1.TestMethod)); } catch (Exception e) { Fail ("#01 Unexpected Exception Thrown: " + e.ToString ()); } }
public void TestJoin1() { C1Test test1 = new C1Test(); C1Test test2 = new C1Test(); Thread thread1 = new Thread(new ThreadStart(test1.TestMethod)); Thread thread2 = new Thread(new ThreadStart(test1.TestMethod2)); try { thread1.Start(); thread2.Start(); thread2.Join(); } catch(Exception e) { Fail("#91 Unexpected Exception " + e.ToString()); } finally { thread1.Abort(); thread2.Abort(); } }