Skip to content

Commit b52c518

Browse files
authored
Refactor Assert methods (#255)
1 parent 551ac18 commit b52c518

File tree

10 files changed

+1299
-1760
lines changed

10 files changed

+1299
-1760
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace NFUnitTest.Mock
2+
{
3+
internal class MockObject
4+
{
5+
}
6+
}

poc/TestOfTestFrameworkByReference/NFUnitTestByReference.nfproj

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</PropertyGroup>
2929
<ItemGroup>
3030
<Compile Include="DataRowTests.cs" />
31+
<Compile Include="Mock\MockObject.cs" />
3132
<Compile Include="SkipFewMethods.cs" />
3233
<Compile Include="SkipTestClass.cs" />
3334
<Compile Include="Test.cs" />

poc/TestOfTestFrameworkByReference/Test.cs

+201-123
Large diffs are not rendered by default.

source/TestFramework/Assert.AreEqual.cs

+244
Large diffs are not rendered by default.

source/TestFramework/Assert.AreNotEqual.cs

+242
Large diffs are not rendered by default.

source/TestFramework/Assert.Obsolete.cs

+428
Large diffs are not rendered by default.

source/TestFramework/Assert.cs

+162-1,616
Large diffs are not rendered by default.

source/TestFramework/CollectionAssert.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
using System.Collections;
9+
using TestFrameworkShared;
910

1011
namespace nanoFramework.TestFramework
1112
{
@@ -33,7 +34,7 @@ public sealed class CollectionAssert
3334
/// <exception cref=""></exception>
3435
public static void Empty(ICollection collection, string message = "")
3536
{
36-
Assert.CheckParameterNotNull(collection, "CollectionAssert.Empty", "collection", string.Empty);
37+
Assert.EnsureParameterIsNotNull(collection, "CollectionAssert.Empty");
3738

3839
if (collection.Count != 0)
3940
{
@@ -49,7 +50,7 @@ public static void Empty(ICollection collection, string message = "")
4950
/// <exception cref="AssertFailedException">Raises an exception if the collection is not empty.</exception>
5051
public static void NotEmpty(ICollection collection, string message = "")
5152
{
52-
Assert.CheckParameterNotNull(collection, "CollectionAssert.NotEmpty", "collection", string.Empty);
53+
Assert.EnsureParameterIsNotNull(collection, "CollectionAssert.NotEmpty");
5354

5455
if (collection.Count == 0)
5556
{

source/TestFramework/nanoFramework.TestFramework.nfproj

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@
3131
</PropertyGroup>
3232
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
3333
<ItemGroup>
34+
<Compile Include="Assert.cs" />
35+
<Compile Include="Assert.AreEqual.cs">
36+
<DependentUpon>Assert.cs</DependentUpon>
37+
</Compile>
38+
<Compile Include="Assert.AreNotEqual.cs">
39+
<DependentUpon>Assert.cs</DependentUpon>
40+
</Compile>
41+
<Compile Include="Assert.Obsolete.cs">
42+
<DependentUpon>Assert.cs</DependentUpon>
43+
</Compile>
3444
<Compile Include="CollectionAssert.cs" />
3545
<Compile Include="OutputHelper.cs" />
3646
<Compile Include="TestExtensions.cs" />
37-
<Compile Include="Assert.cs" />
3847
</ItemGroup>
3948
<ItemGroup>
4049
<Compile Include="Properties\AssemblyInfo.cs" />

source/TestFrameworkShared/SkipTestException.cs

+2-18
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,17 @@
99
namespace nanoFramework.TestFramework
1010
{
1111
/// <summary>
12-
/// To skip a test, raise this exception thru the Assert.SkipTest("some message");
12+
/// To skip a test, raise this exception through the Assert.SkipTest("some message");
1313
/// </summary>
1414
public class SkipTestException : Exception
1515
{
16-
/// <summary>
17-
/// Initializes a new instance of the SkipTestException class.
18-
/// </summary>
19-
public SkipTestException()
20-
: base()
21-
{ }
22-
23-
/// <summary>
24-
/// Initializes a new instance of the SkipTestException class with a specified error message.
25-
/// </summary>
26-
/// <param name="message">The message that describes the error.</param>
27-
public SkipTestException(string message)
28-
: base(message)
29-
{ }
30-
3116
/// <summary>
3217
/// Initializes a new instance of the SkipTestException class with a specified error message
3318
/// and a reference to the inner SkipTestException that is the cause of this exception.
3419
/// </summary>
3520
/// <param name="message">The message that describes the error.</param>
3621
/// <param name="innerException"></param>
37-
public SkipTestException(string message, Exception innerException)
38-
: base(message, innerException)
22+
public SkipTestException(string message = null, Exception innerException = null) : base(message, innerException)
3923
{ }
4024
}
4125
}

0 commit comments

Comments
 (0)