From 61c858cb1ce132e0f1f050fe47799a08487d7d0a Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Sun, 12 Feb 2012 13:46:19 +0000 Subject: [PATCH] CanGetProcessThreadForManagedThread() test now only runs on Windows systems; removed unused variable from expression tree cloner; removed unused variable from unit test of weak collection; fixed test issue parsing command lines relying on current platform being windows; removed unused variable from Semaphore class git-svn-id: file:///srv/devel/repo-conversion/nusu@251 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/AffineThreadPool.Test.cs | 23 ++++++++++--------- .../ExpressionTreeCloner.FieldBased.cs | 1 - Source/Collections/WeakCollection.Test.cs | 1 - Source/Parsing/CommandLine.Test.cs | 17 ++++++++++++-- Source/Semaphore.cs | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Source/AffineThreadPool.Test.cs b/Source/AffineThreadPool.Test.cs index 1501743..5fb8446 100644 --- a/Source/AffineThreadPool.Test.cs +++ b/Source/AffineThreadPool.Test.cs @@ -235,18 +235,19 @@ namespace Nuclex.Support { /// be determined using the GetProcessThread() method /// [Test] - public void TestGetProcessThread() { - Thread.BeginThreadAffinity(); - try { - int threadId = AffineThreadPool.GetCurrentThreadId(); + public void CanGetProcessThreadForManagedThread() { + if(Environment.OSVersion.Platform == PlatformID.Win32NT) { + Thread.BeginThreadAffinity(); + try { + int threadId = AffineThreadPool.GetCurrentThreadId(); - Assert.IsNotNull(AffineThreadPool.GetProcessThread(threadId)); - Assert.IsNull(AffineThreadPool.GetProcessThread(0)); + Assert.IsNotNull(AffineThreadPool.GetProcessThread(threadId)); + Assert.IsNull(AffineThreadPool.GetProcessThread(0)); + } + finally { + Thread.EndThreadAffinity(); + } } - finally { - Thread.EndThreadAffinity(); - } - } /// @@ -299,7 +300,7 @@ namespace Nuclex.Support { "Task " + index.ToString() + " was started" ); } - + // All Thread should now be active and no work items should be waiting Assert.AreEqual( createdTasks, AffineThreadPool.ActiveThreads, diff --git a/Source/Cloning/ExpressionTreeCloner.FieldBased.cs b/Source/Cloning/ExpressionTreeCloner.FieldBased.cs index f7b7f08..9bad0d2 100644 --- a/Source/Cloning/ExpressionTreeCloner.FieldBased.cs +++ b/Source/Cloning/ExpressionTreeCloner.FieldBased.cs @@ -261,7 +261,6 @@ namespace Nuclex.Support.Cloning { variables.Add(clone); int dimensionCount = clonedType.GetArrayRank(); - int baseVariableIndex = variables.Count; Type elementType = clonedType.GetElementType(); var lengths = new List(); diff --git a/Source/Collections/WeakCollection.Test.cs b/Source/Collections/WeakCollection.Test.cs index 7429816..e2997f4 100644 --- a/Source/Collections/WeakCollection.Test.cs +++ b/Source/Collections/WeakCollection.Test.cs @@ -410,7 +410,6 @@ namespace Nuclex.Support.Collections { Dummy oneTwoThreeDummy = new Dummy(123); dummies.Add(oneTwoThreeDummy); - Dummy fourFiveSixDummy = new Dummy(456); Assert.Throws( delegate() { (dummies as IList).Insert(0, new object()); } ); diff --git a/Source/Parsing/CommandLine.Test.cs b/Source/Parsing/CommandLine.Test.cs index ce40d00..65d1b67 100644 --- a/Source/Parsing/CommandLine.Test.cs +++ b/Source/Parsing/CommandLine.Test.cs @@ -570,8 +570,21 @@ namespace Nuclex.Support.Parsing { /// Tests whether the existence of named arguments can be checked /// [Test] - public void TestHasArgument() { - CommandLine test = CommandLine.Parse("/first:x /second:y /second:z third"); + public void HasArgumentWorksForWindowsStyleArguments() { + CommandLine test = CommandLine.Parse("/first:x /second:y /second:z third", true); + + Assert.IsTrue(test.HasArgument("first")); + Assert.IsTrue(test.HasArgument("second")); + Assert.IsFalse(test.HasArgument("third")); + Assert.IsFalse(test.HasArgument("fourth")); + } + + /// + /// Tests whether the existence of named arguments can be checked + /// + [Test] + public void HasArgumentWorksForUnixStyleArguments() { + CommandLine test = CommandLine.Parse("--first=x --second=y --second=z third", false); Assert.IsTrue(test.HasArgument("first")); Assert.IsTrue(test.HasArgument("second")); diff --git a/Source/Semaphore.cs b/Source/Semaphore.cs index 8042adf..1fa2f23 100644 --- a/Source/Semaphore.cs +++ b/Source/Semaphore.cs @@ -219,7 +219,7 @@ namespace Nuclex.Support { public void Release() { // Release one lock on the resource - int newFree = Interlocked.Increment(ref this.free); + Interlocked.Increment(ref this.free); // Wake up any threads waiting for the resource to become available this.manualResetEvent.Set();