public virtual void TestFailsMethodsOnBackgroundThread() { ThreadSafeProgressMonitorTest.MockProgressMonitor mock = new ThreadSafeProgressMonitorTest.MockProgressMonitor (); ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); RunOnThread(new _Runnable_64(pm)); // Expected result // Expected result // Expected result // Ensure we didn't alter the mock above when checking threads. NUnit.Framework.Assert.IsNull(mock.taskTitle); NUnit.Framework.Assert.AreEqual(0, mock.value); }
public virtual void TestMethodsOkOnMainThread() { ThreadSafeProgressMonitorTest.MockProgressMonitor mock = new ThreadSafeProgressMonitorTest.MockProgressMonitor (); ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); pm.Start(1); NUnit.Framework.Assert.AreEqual(1, mock.value); pm.BeginTask("title", 42); NUnit.Framework.Assert.AreEqual("title", mock.taskTitle); NUnit.Framework.Assert.AreEqual(42, mock.value); pm.Update(1); NUnit.Framework.Assert.AreEqual(43, mock.value); pm.Update(2); NUnit.Framework.Assert.AreEqual(45, mock.value); pm.EndTask(); NUnit.Framework.Assert.IsNull(mock.taskTitle); NUnit.Framework.Assert.AreEqual(0, mock.value); }
public virtual void TestUpdateOnBackgroundThreads() { ThreadSafeProgressMonitorTest.MockProgressMonitor mock = new ThreadSafeProgressMonitorTest.MockProgressMonitor (); ThreadSafeProgressMonitor pm = new ThreadSafeProgressMonitor(mock); pm.StartWorker(); CountDownLatch doUpdate = new CountDownLatch(1); CountDownLatch didUpdate = new CountDownLatch(1); CountDownLatch doEndWorker = new CountDownLatch(1); Sharpen.Thread bg = new _Thread_128(pm, doUpdate, didUpdate, doEndWorker); bg.Start(); pm.PollForUpdates(); NUnit.Framework.Assert.AreEqual(0, mock.value); doUpdate.CountDown(); Await(didUpdate); pm.PollForUpdates(); NUnit.Framework.Assert.AreEqual(2, mock.value); doEndWorker.CountDown(); pm.WaitForCompletion(); NUnit.Framework.Assert.AreEqual(3, mock.value); }