Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/nunit/src/NUnitCore/ActiveTestSuite.cs')
-rw-r--r--mcs/nunit/src/NUnitCore/ActiveTestSuite.cs188
1 files changed, 104 insertions, 84 deletions
diff --git a/mcs/nunit/src/NUnitCore/ActiveTestSuite.cs b/mcs/nunit/src/NUnitCore/ActiveTestSuite.cs
index 605911d233c..cdba3b0ed9b 100644
--- a/mcs/nunit/src/NUnitCore/ActiveTestSuite.cs
+++ b/mcs/nunit/src/NUnitCore/ActiveTestSuite.cs
@@ -1,93 +1,113 @@
-namespace NUnit.Extensions {
-
- using System;
- using System.Threading;
+namespace NUnit.Extensions
+{
+ using System;
+ using System.Threading;
+ using NUnit.Framework;
- using NUnit.Framework;
-
- /// <summary>A TestSuite for active Tests. It runs each
- /// test in a separate thread and until all
- /// threads have terminated.
- /// -- Aarhus Radisson Scandinavian Center 11th floor</summary>
- public class ActiveTestSuite: TestSuite {
- private int fActiveTestDeathCount;
/// <summary>
- ///
+ /// A TestSuite for active Tests. It runs each test in a
+ /// separate thread and until all threads have terminated.
+ /// -- Aarhus Radisson Scandinavian Center 11th floor
/// </summary>
- /// <param name="result"></param>
- public override void Run(TestResult result) {
- fActiveTestDeathCount= 0;
- base.Run(result);
- WaitUntilFinished();
- }
- /// <summary>
- ///
- /// </summary>
- public class ThreadLittleHelper {
- private ITest fTest;
- private TestResult fResult;
- private ActiveTestSuite fSuite;
+ public class ActiveTestSuite: TestSuite
+ {
+ private int fActiveTestDeathCount;
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="result"></param>
+ public override void Run(TestResult result)
+ {
+ fActiveTestDeathCount= 0;
+ base.Run(result);
+ WaitUntilFinished();
+ }
/// <summary>
///
/// </summary>
/// <param name="test"></param>
/// <param name="result"></param>
- /// <param name="suite"></param>
- public ThreadLittleHelper(ITest test, TestResult result,
- ActiveTestSuite suite) {
- fSuite = suite;
- fTest = test;
- fResult = result;
- }
- /// <summary>
- ///
- /// </summary>
- public void Run() {
- try {
- fSuite.BaseRunTest(fTest, fResult);
- } finally {
- fSuite.RunFinished(fTest);
- }
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="test"></param>
- /// <param name="result"></param>
- public void BaseRunTest(ITest test, TestResult result) {
- base.RunTest(test, result);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="test"></param>
- /// <param name="result"></param>
- public override void RunTest(ITest test, TestResult result) {
- ThreadLittleHelper tlh = new ThreadLittleHelper(test, result, this);
- Thread t = new Thread(new ThreadStart(tlh.Run));
- t.Start();
- }
- void WaitUntilFinished() {
- lock(this) {
- while (fActiveTestDeathCount < TestCount) {
- try {
- Monitor.Wait(this);
- } catch (ThreadInterruptedException) {
- return; // TBD
- }
- }
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="test"></param>
- public void RunFinished(ITest test) {
- lock(this) {
- fActiveTestDeathCount++;
- Monitor.PulseAll(this);
- }
- }
- }
+ public void BaseRunTest(ITest test, TestResult result)
+ {
+ base.RunTest(test, result);
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="test"></param>
+ /// <param name="result"></param>
+ public override void RunTest(ITest test, TestResult result)
+ {
+ ThreadLittleHelper tlh = new ThreadLittleHelper(test, result, this);
+ Thread t = new Thread(new ThreadStart(tlh.Run));
+ t.Start();
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="test"></param>
+ public void RunFinished(ITest test)
+ {
+ lock(this)
+ {
+ fActiveTestDeathCount++;
+ Monitor.PulseAll(this);
+ }
+ }
+ private void WaitUntilFinished()
+ {
+ lock(this)
+ {
+ while (fActiveTestDeathCount < TestCount)
+ {
+ try
+ {
+ Monitor.Wait(this);
+ }
+ catch (ThreadInterruptedException)
+ {
+ return; // TBD
+ }
+ }
+ }
+ }
+ #region Nested Classes
+ /// <summary>
+ ///
+ /// </summary>
+ public class ThreadLittleHelper
+ {
+ private ITest fTest;
+ private TestResult fResult;
+ private ActiveTestSuite fSuite;
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="test"></param>
+ /// <param name="result"></param>
+ /// <param name="suite"></param>
+ public ThreadLittleHelper(ITest test, TestResult result,
+ ActiveTestSuite suite)
+ {
+ fSuite = suite;
+ fTest = test;
+ fResult = result;
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ public void Run()
+ {
+ try
+ {
+ fSuite.BaseRunTest(fTest, fResult);
+ }
+ finally
+ {
+ fSuite.RunFinished(fTest);
+ }
+ }
+ }
+ #endregion
+ }
}