From a2b92248b51b37d0171bdb03531496b09b0f8715 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Thu, 20 Feb 2014 14:49:08 +0000 Subject: [PATCH] Parallel background worker unit tests are now internal again; added missing comments; nested unit test files under the implementation files they are testing git-svn-id: file:///srv/devel/repo-conversion/nusu@292 d2e56fa2-650e-0410-a79f-9358c0239efd --- Nuclex.Support (net-4.0).csproj | 8 +++++--- Source/ParallelBackgroundWorker.Test.cs | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Nuclex.Support (net-4.0).csproj b/Nuclex.Support (net-4.0).csproj index 9378f3d..14255fb 100644 --- a/Nuclex.Support (net-4.0).csproj +++ b/Nuclex.Support (net-4.0).csproj @@ -214,8 +214,7 @@ LicenseKey.cs - - + CommandLine.cs @@ -225,10 +224,13 @@ CommandLine.cs - CommandLine.cs + + + ParallelBackgroundWorker.cs + ParserHelper.cs diff --git a/Source/ParallelBackgroundWorker.Test.cs b/Source/ParallelBackgroundWorker.Test.cs index f8835e1..f1c56a7 100644 --- a/Source/ParallelBackgroundWorker.Test.cs +++ b/Source/ParallelBackgroundWorker.Test.cs @@ -19,20 +19,22 @@ License along with this library #endregion using System; -using System.IO; +using System.Threading; +using System.Collections.Generic; #if UNITTEST using NUnit.Framework; -using System.Threading; -using System.Collections.Generic; namespace Nuclex.Support { /// Unit Test for the parallel background worker class [TestFixture] - public class ParallelBackgroundWorkerTest { + internal class ParallelBackgroundWorkerTest { + #region class TestWorker + + /// Implementation of a background worker used for unit testing private class TestWorker : ParallelBackgroundWorker { /// Initializes a new parallel background worker with unlimited threads @@ -51,14 +53,14 @@ namespace Nuclex.Support { /// be created, so specifying -2 on a single-core system will still occupy /// the only core. /// - public TestWorker(int threadCount) : base(threadCount) {} + public TestWorker(int threadCount) : base(threadCount) { } /// /// Initializes a new parallel background worker that uses the specified name for /// its worker threads. /// /// Name that will be assigned to the worker threads - public TestWorker(string name) : base(name) {} + public TestWorker(string name) : base(name) { } /// /// Initializes a new parallel background worker that uses the specified name for @@ -97,13 +99,20 @@ namespace Nuclex.Support { } } + /// Whether the work tasks should throw exceptions public bool ThrowException; + /// Event that can be used to stop work tasks from completing public ManualResetEvent WaitEvent; + + /// Set by work tasks if they have been cancelled public bool WasCancelled; + /// Work tasks that have reached execution public ICollection Tasks; } + #endregion // class TestWorker + /// Verifies that the background worker has a default constructor [Test] public void CanBeDefaultConstructed() { @@ -196,7 +205,7 @@ namespace Nuclex.Support { testWorker.AddTask(new object()); testWorker.CancelRunningTasks(); - + waitEvent.Set(); Assert.IsTrue(testWorker.Wait(1000));