From 079fe8b1cd7f3111b3d9ab69814fe4a16159b10f Mon Sep 17 00:00:00 2001 From: cygon Date: Wed, 24 Jul 2024 17:42:17 +0200 Subject: [PATCH] Removed UNITTEST constant from most files; tried switching to Moq, but encountered some InternalsVisibleTo() problems; ripped out NuGet again because it is so very bad --- Nuclex.Support.Tests (netstandard-2.0).csproj | 8 ++--- Properties/AssemblyInfo.cs | 16 ++++++++- {Source => Tests}/Cloning/CloneFactoryTest.cs | 4 --- Tests/Cloning/ExpressionTreeClonerTest.cs | 4 --- Tests/Cloning/ReflectionClonerTest.cs | 4 --- Tests/Cloning/SerializationClonerTest.cs | 4 --- Tests/Collections/ConstantsTest.cs | 4 --- Tests/Collections/DequeTest.cs | 4 --- Tests/Collections/IListExtensionsTest.cs | 4 --- Tests/Collections/ItemEventArgsTest.cs | 4 --- Tests/Collections/ItemReplaceEventArgsTest.cs | 4 --- Tests/Collections/ListSegmentTest.cs | 4 --- Tests/Collections/MultiDictionaryTest.cs | 5 --- Tests/Collections/ObservableCollectionTest.cs | 35 ++++++------------- Tests/IO/ChainStreamTest.cs | 4 --- Tests/IO/PartialStreamTest.cs | 4 --- Tests/IO/RingMemoryStreamTest.cs | 6 +--- Tests/Licensing/LicenseKeyTest.cs | 4 --- Tests/Parsing/CommandLineTest.cs | 4 --- Tests/Parsing/ParserHelperTest.cs | 4 --- Tests/Settings/ConfigurationFileStoreTest.cs | 4 --- Tests/Settings/MemoryStoreTest.cs | 4 --- Tests/Settings/WindowsRegistryStoreTest.cs | 4 +-- Tests/Threading/AffineThreadPoolTest.cs | 4 --- .../Threading/ParallelBackgroundWorkerTest.cs | 4 --- Tests/Threading/ThreadRunnerTest.cs | 4 --- 26 files changed, 31 insertions(+), 123 deletions(-) rename {Source => Tests}/Cloning/CloneFactoryTest.cs (99%) diff --git a/Nuclex.Support.Tests (netstandard-2.0).csproj b/Nuclex.Support.Tests (netstandard-2.0).csproj index 54b3bfd..f18fe95 100644 --- a/Nuclex.Support.Tests (netstandard-2.0).csproj +++ b/Nuclex.Support.Tests (netstandard-2.0).csproj @@ -21,10 +21,6 @@ - - - - @@ -33,8 +29,8 @@ ..\third-party\castle.core-5.1.1\netstandard-2.0\Castle.Core.dll - - ..\third-party\nsubstitute-5.1.0\netstandard-2.0\NSubstitute.dll + + ..\third-party\moq-4.20.70\netstandard-2.0\Moq.dll ..\third-party\nunit-3.14.0\netstandard-2.0\nunit.framework.dll diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 4b45d5d..b061932 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -40,12 +40,26 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("1308e4c3-a0c1-423a-aaae-61c7314777e0")] -#if UNITTEST +#if false // NMock is being removed // This is required to NMock can derive its proxies from interfaces in // the internal unit test classes [assembly: InternalsVisibleTo(NMock.Constants.InternalsVisibleToDynamicProxy)] #endif +//[assembly: InternalsVisibleTo(NMock.Constants.InternalsVisibleToDynamicProxy)] + +[assembly: InternalsVisibleTo("Nuclex.Support.Tests")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] +[ + assembly: InternalsVisibleTo( + "DynamicProxyGenAssembly2," + + "PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac3" + + "7abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d92666" + + "54753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad" + + "2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" + ) +] + // Version information for an assembly consists of the following four values: // // Major Version diff --git a/Source/Cloning/CloneFactoryTest.cs b/Tests/Cloning/CloneFactoryTest.cs similarity index 99% rename from Source/Cloning/CloneFactoryTest.cs rename to Tests/Cloning/CloneFactoryTest.cs index 3a4f1f4..90cf4ea 100644 --- a/Source/Cloning/CloneFactoryTest.cs +++ b/Tests/Cloning/CloneFactoryTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using NUnit.Framework; @@ -592,5 +590,3 @@ namespace Nuclex.Support.Cloning { } } // namespace Nuclex.Support.Cloning - -#endif // UNITTEST diff --git a/Tests/Cloning/ExpressionTreeClonerTest.cs b/Tests/Cloning/ExpressionTreeClonerTest.cs index c774932..e818f77 100644 --- a/Tests/Cloning/ExpressionTreeClonerTest.cs +++ b/Tests/Cloning/ExpressionTreeClonerTest.cs @@ -19,8 +19,6 @@ limitations under the License. #if !NO_SETS -#if UNITTEST - using System; using System.Collections.Generic; @@ -220,6 +218,4 @@ namespace Nuclex.Support.Cloning { } // namespace Nuclex.Support.Cloning -#endif // UNITTEST - #endif // !NO_SETS diff --git a/Tests/Cloning/ReflectionClonerTest.cs b/Tests/Cloning/ReflectionClonerTest.cs index 2bd7acf..4b301c8 100644 --- a/Tests/Cloning/ReflectionClonerTest.cs +++ b/Tests/Cloning/ReflectionClonerTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; @@ -194,5 +192,3 @@ namespace Nuclex.Support.Cloning { } } // namespace Nuclex.Support.Cloning - -#endif // UNITTEST diff --git a/Tests/Cloning/SerializationClonerTest.cs b/Tests/Cloning/SerializationClonerTest.cs index 3a42e67..df55590 100644 --- a/Tests/Cloning/SerializationClonerTest.cs +++ b/Tests/Cloning/SerializationClonerTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; @@ -141,5 +139,3 @@ namespace Nuclex.Support.Cloning { } } // namespace Nuclex.Support.Cloning - -#endif // UNITTEST diff --git a/Tests/Collections/ConstantsTest.cs b/Tests/Collections/ConstantsTest.cs index a0ac65a..53ac08d 100644 --- a/Tests/Collections/ConstantsTest.cs +++ b/Tests/Collections/ConstantsTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Specialized; @@ -48,5 +46,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/DequeTest.cs b/Tests/Collections/DequeTest.cs index 6102643..b778623 100644 --- a/Tests/Collections/DequeTest.cs +++ b/Tests/Collections/DequeTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections; using System.Collections.Generic; @@ -706,5 +704,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/IListExtensionsTest.cs b/Tests/Collections/IListExtensionsTest.cs index 6ca66e4..7443351 100644 --- a/Tests/Collections/IListExtensionsTest.cs +++ b/Tests/Collections/IListExtensionsTest.cs @@ -21,8 +21,6 @@ using System; using System.Collections.Generic; using System.IO; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.Collections { @@ -132,5 +130,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/ItemEventArgsTest.cs b/Tests/Collections/ItemEventArgsTest.cs index 62f4f9f..0df5071 100644 --- a/Tests/Collections/ItemEventArgsTest.cs +++ b/Tests/Collections/ItemEventArgsTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; @@ -51,5 +49,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/ItemReplaceEventArgsTest.cs b/Tests/Collections/ItemReplaceEventArgsTest.cs index 2cdaf32..3cec33c 100644 --- a/Tests/Collections/ItemReplaceEventArgsTest.cs +++ b/Tests/Collections/ItemReplaceEventArgsTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; @@ -53,5 +51,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/ListSegmentTest.cs b/Tests/Collections/ListSegmentTest.cs index 04b2c7b..f898a81 100644 --- a/Tests/Collections/ListSegmentTest.cs +++ b/Tests/Collections/ListSegmentTest.cs @@ -21,8 +21,6 @@ using System; using System.Collections.Generic; using System.IO; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.Collections { @@ -252,5 +250,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/MultiDictionaryTest.cs b/Tests/Collections/MultiDictionaryTest.cs index 0c72383..8033a88 100644 --- a/Tests/Collections/MultiDictionaryTest.cs +++ b/Tests/Collections/MultiDictionaryTest.cs @@ -17,13 +17,10 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; using NUnit.Framework; -using NMock; namespace Nuclex.Support.Collections { @@ -386,5 +383,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST diff --git a/Tests/Collections/ObservableCollectionTest.cs b/Tests/Collections/ObservableCollectionTest.cs index b95d20f..88e0c7c 100644 --- a/Tests/Collections/ObservableCollectionTest.cs +++ b/Tests/Collections/ObservableCollectionTest.cs @@ -17,16 +17,12 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if !NO_NMOCK - using System; using System.Collections.Generic; -#if UNITTEST - using NUnit.Framework; -using NMock; - +using Moq; + namespace Nuclex.Support.Collections { /// Unit Test for the observable collection class @@ -65,35 +61,32 @@ namespace Nuclex.Support.Collections { /// Initialization routine executed before each test is run [SetUp] public void Setup() { - this.mockery = new MockFactory(); - - this.mockedSubscriber = this.mockery.CreateMock(); + this.mockedSubscriber = new Mock(); this.observedCollection = new ObservableCollection(); this.observedCollection.Clearing += new EventHandler( - this.mockedSubscriber.MockObject.Clearing + this.mockedSubscriber.Object.Clearing ); this.observedCollection.Cleared += new EventHandler( - this.mockedSubscriber.MockObject.Cleared + this.mockedSubscriber.Object.Cleared ); this.observedCollection.ItemAdded += new EventHandler>( - this.mockedSubscriber.MockObject.ItemAdded + this.mockedSubscriber.Object.ItemAdded ); this.observedCollection.ItemRemoved += new EventHandler>( - this.mockedSubscriber.MockObject.ItemRemoved + this.mockedSubscriber.Object.ItemRemoved ); } /// Tests whether the Clearing event is fired [Test] public void TestClearingEvent() { - this.mockedSubscriber.Expects.One.Method(m => m.Clearing(null, null)).WithAnyArguments(); - this.mockedSubscriber.Expects.One.Method(m => m.Cleared(null, null)).WithAnyArguments(); this.observedCollection.Clear(); - this.mockery.VerifyAllExpectationsHaveBeenMet(); + this.mockedSubscriber.Verify(c => c.Clearing(null, null), Times.Once); + this.mockedSubscriber.Verify(c => c.Cleared(null, null), Times.Once); } - +/* /// Tests whether the ItemAdded event is fired [Test] public void TestItemAddedEvent() { @@ -127,9 +120,7 @@ namespace Nuclex.Support.Collections { CollectionAssert.AreEqual(integers, testCollection); } - - /// Mock object factory - private MockFactory mockery; +*/ /// The mocked observable collection subscriber private Mock mockedSubscriber; /// An observable collection to which a mock will be subscribed @@ -138,7 +129,3 @@ namespace Nuclex.Support.Collections { } } // namespace Nuclex.Support.Collections - -#endif // UNITTEST - -#endif // !NO_NMOCK diff --git a/Tests/IO/ChainStreamTest.cs b/Tests/IO/ChainStreamTest.cs index 92c5e94..7ab14fb 100644 --- a/Tests/IO/ChainStreamTest.cs +++ b/Tests/IO/ChainStreamTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.IO; @@ -557,5 +555,3 @@ namespace Nuclex.Support.IO { } } // namespace Nuclex.Support.IO - -#endif // UNITTEST diff --git a/Tests/IO/PartialStreamTest.cs b/Tests/IO/PartialStreamTest.cs index b928e7b..8716003 100644 --- a/Tests/IO/PartialStreamTest.cs +++ b/Tests/IO/PartialStreamTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.IO; @@ -522,5 +520,3 @@ namespace Nuclex.Support.IO { } } // namespace Nuclex.Support.IO - -#endif // UNITTEST diff --git a/Tests/IO/RingMemoryStreamTest.cs b/Tests/IO/RingMemoryStreamTest.cs index c71092f..7cdd210 100644 --- a/Tests/IO/RingMemoryStreamTest.cs +++ b/Tests/IO/RingMemoryStreamTest.cs @@ -20,8 +20,6 @@ limitations under the License. using System; using System.IO; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.IO { @@ -31,7 +29,7 @@ namespace Nuclex.Support.IO { internal class RingMemoryStreamTest { /// Prepares some test data for the units test methods - [TestFixtureSetUp] + [OneTimeSetUp] public void Setup() { this.testBytes = new byte[20]; for(int i = 0; i < 20; ++i) @@ -325,5 +323,3 @@ namespace Nuclex.Support.IO { } } // namespace Nuclex.Support.IO - -#endif // UNITTEST diff --git a/Tests/Licensing/LicenseKeyTest.cs b/Tests/Licensing/LicenseKeyTest.cs index 50cbea9..f672f61 100644 --- a/Tests/Licensing/LicenseKeyTest.cs +++ b/Tests/Licensing/LicenseKeyTest.cs @@ -20,8 +20,6 @@ limitations under the License. using System; using System.Collections; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.Licensing { @@ -137,5 +135,3 @@ namespace Nuclex.Support.Licensing { } } // namespace Nuclex.Support.Licensing - -#endif // UNITTEST diff --git a/Tests/Parsing/CommandLineTest.cs b/Tests/Parsing/CommandLineTest.cs index e9324ab..af6733a 100644 --- a/Tests/Parsing/CommandLineTest.cs +++ b/Tests/Parsing/CommandLineTest.cs @@ -19,8 +19,6 @@ limitations under the License. using System; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.Parsing { @@ -653,5 +651,3 @@ namespace Nuclex.Support.Parsing { } } // namespace Nuclex.Support.Parsing - -#endif // UNITTEST diff --git a/Tests/Parsing/ParserHelperTest.cs b/Tests/Parsing/ParserHelperTest.cs index 63cf662..dd7125b 100644 --- a/Tests/Parsing/ParserHelperTest.cs +++ b/Tests/Parsing/ParserHelperTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; using System.Text; @@ -228,5 +226,3 @@ namespace Nuclex.Support.Parsing { } } // namespace Nuclex.Support.Parsing - -#endif // UNITTEST diff --git a/Tests/Settings/ConfigurationFileStoreTest.cs b/Tests/Settings/ConfigurationFileStoreTest.cs index 0d83b72..12bfa3e 100644 --- a/Tests/Settings/ConfigurationFileStoreTest.cs +++ b/Tests/Settings/ConfigurationFileStoreTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; using System.IO; @@ -462,5 +460,3 @@ namespace Nuclex.Support.Settings { } } // namespace Nuclex.Support.Settings - -#endif // UNITTEST diff --git a/Tests/Settings/MemoryStoreTest.cs b/Tests/Settings/MemoryStoreTest.cs index 2df67cc..937773e 100644 --- a/Tests/Settings/MemoryStoreTest.cs +++ b/Tests/Settings/MemoryStoreTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; @@ -160,5 +158,3 @@ namespace Nuclex.Support.Settings { } } // namespace Nuclex.Support.Settings - -#endif // UNITTEST diff --git a/Tests/Settings/WindowsRegistryStoreTest.cs b/Tests/Settings/WindowsRegistryStoreTest.cs index 3d37e35..3be99a0 100644 --- a/Tests/Settings/WindowsRegistryStoreTest.cs +++ b/Tests/Settings/WindowsRegistryStoreTest.cs @@ -17,7 +17,7 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST && WINDOWS +#if WINDOWS using System; using System.Collections.Generic; @@ -362,4 +362,4 @@ namespace Nuclex.Support.Settings { } // namespace Nuclex.Support.Settings -#endif // UNITTEST +#endif // WINDOWS diff --git a/Tests/Threading/AffineThreadPoolTest.cs b/Tests/Threading/AffineThreadPoolTest.cs index 2aeac2c..047b7f3 100644 --- a/Tests/Threading/AffineThreadPoolTest.cs +++ b/Tests/Threading/AffineThreadPoolTest.cs @@ -17,8 +17,6 @@ limitations under the License. */ #endregion // Apache License 2.0 -#if UNITTEST - using System; using System.Collections.Generic; using System.Threading; @@ -351,5 +349,3 @@ namespace Nuclex.Support.Threading { } } // namespace Nuclex.Support.Threading - -#endif // UNITTEST diff --git a/Tests/Threading/ParallelBackgroundWorkerTest.cs b/Tests/Threading/ParallelBackgroundWorkerTest.cs index fd73fab..69a1cd2 100644 --- a/Tests/Threading/ParallelBackgroundWorkerTest.cs +++ b/Tests/Threading/ParallelBackgroundWorkerTest.cs @@ -23,8 +23,6 @@ using System; using System.Threading; using System.Collections.Generic; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.Threading { @@ -252,6 +250,4 @@ namespace Nuclex.Support.Threading { } // namespace Nuclex.Support.Threading -#endif // UNITTEST - #endif // !NO_CONCURRENT_COLLECTIONS diff --git a/Tests/Threading/ThreadRunnerTest.cs b/Tests/Threading/ThreadRunnerTest.cs index c5058a9..13a46ac 100644 --- a/Tests/Threading/ThreadRunnerTest.cs +++ b/Tests/Threading/ThreadRunnerTest.cs @@ -23,8 +23,6 @@ using System; using System.Threading; using System.Collections.Generic; -#if UNITTEST - using NUnit.Framework; namespace Nuclex.Support.Threading { @@ -454,6 +452,4 @@ namespace Nuclex.Support.Threading { } // namespace Nuclex.Support.Threading -#endif // UNITTEST - #endif // !NO_CONCURRENT_COLLECTIONS