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

This commit is contained in:
cygon 2024-07-24 17:42:17 +02:00
parent 56c6b649a7
commit 079fe8b1cd
26 changed files with 31 additions and 123 deletions

View File

@ -21,10 +21,6 @@
<None Remove="packages.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NSubstitute" Version="5.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Nuclex.Support (netstandard-2.0).csproj" />
</ItemGroup>
@ -33,8 +29,8 @@
<Reference Include="Castle.Core">
<HintPath>..\third-party\castle.core-5.1.1\netstandard-2.0\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="NSubstitute">
<HintPath>..\third-party\nsubstitute-5.1.0\netstandard-2.0\NSubstitute.dll</HintPath>
<Reference Include="Moq">
<HintPath>..\third-party\moq-4.20.70\netstandard-2.0\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\third-party\nunit-3.14.0\netstandard-2.0\nunit.framework.dll</HintPath>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {
/// <summary>Unit Test for the observable collection class</summary>
@ -65,35 +61,32 @@ namespace Nuclex.Support.Collections {
/// <summary>Initialization routine executed before each test is run</summary>
[SetUp]
public void Setup() {
this.mockery = new MockFactory();
this.mockedSubscriber = this.mockery.CreateMock<IObservableCollectionSubscriber>();
this.mockedSubscriber = new Mock<IObservableCollectionSubscriber>();
this.observedCollection = new ObservableCollection<int>();
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<ItemEventArgs<int>>(
this.mockedSubscriber.MockObject.ItemAdded
this.mockedSubscriber.Object.ItemAdded
);
this.observedCollection.ItemRemoved += new EventHandler<ItemEventArgs<int>>(
this.mockedSubscriber.MockObject.ItemRemoved
this.mockedSubscriber.Object.ItemRemoved
);
}
/// <summary>Tests whether the Clearing event is fired</summary>
[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);
}
/*
/// <summary>Tests whether the ItemAdded event is fired</summary>
[Test]
public void TestItemAddedEvent() {
@ -127,9 +120,7 @@ namespace Nuclex.Support.Collections {
CollectionAssert.AreEqual(integers, testCollection);
}
/// <summary>Mock object factory</summary>
private MockFactory mockery;
*/
/// <summary>The mocked observable collection subscriber</summary>
private Mock<IObservableCollectionSubscriber> mockedSubscriber;
/// <summary>An observable collection to which a mock will be subscribed</summary>
@ -138,7 +129,3 @@ namespace Nuclex.Support.Collections {
}
} // namespace Nuclex.Support.Collections
#endif // UNITTEST
#endif // !NO_NMOCK

View File

@ -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

View File

@ -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

View File

@ -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 {
/// <summary>Prepares some test data for the units test methods</summary>
[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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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