Skip to content

Refactor Assert methods #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions poc/TestOfTestFrameworkByReference/Mock/MockObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace NFUnitTest.Mock
{
internal class MockObject
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="DataRowTests.cs" />
<Compile Include="Mock\MockObject.cs" />
<Compile Include="SkipFewMethods.cs" />
<Compile Include="SkipTestClass.cs" />
<Compile Include="Test.cs" />
Expand Down
324 changes: 201 additions & 123 deletions poc/TestOfTestFrameworkByReference/Test.cs

Large diffs are not rendered by default.

244 changes: 244 additions & 0 deletions source/TestFramework/Assert.AreEqual.cs

Large diffs are not rendered by default.

242 changes: 242 additions & 0 deletions source/TestFramework/Assert.AreNotEqual.cs

Large diffs are not rendered by default.

428 changes: 428 additions & 0 deletions source/TestFramework/Assert.Obsolete.cs

Large diffs are not rendered by default.

1,778 changes: 162 additions & 1,616 deletions source/TestFramework/Assert.cs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions source/TestFramework/CollectionAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


using System.Collections;
using TestFrameworkShared;

namespace nanoFramework.TestFramework
{
Expand Down Expand Up @@ -33,7 +34,7 @@ public sealed class CollectionAssert
/// <exception cref=""></exception>
public static void Empty(ICollection collection, string message = "")
{
Assert.CheckParameterNotNull(collection, "CollectionAssert.Empty", "collection", string.Empty);
Assert.EnsureParameterIsNotNull(collection, "CollectionAssert.Empty");

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

if (collection.Count == 0)
{
Expand Down
11 changes: 10 additions & 1 deletion source/TestFramework/nanoFramework.TestFramework.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<ItemGroup>
<Compile Include="Assert.cs" />
<Compile Include="Assert.AreEqual.cs">
<DependentUpon>Assert.cs</DependentUpon>
</Compile>
<Compile Include="Assert.AreNotEqual.cs">
<DependentUpon>Assert.cs</DependentUpon>
</Compile>
<Compile Include="Assert.Obsolete.cs">
<DependentUpon>Assert.cs</DependentUpon>
</Compile>
<Compile Include="CollectionAssert.cs" />
<Compile Include="OutputHelper.cs" />
<Compile Include="TestExtensions.cs" />
<Compile Include="Assert.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
20 changes: 2 additions & 18 deletions source/TestFrameworkShared/SkipTestException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,17 @@
namespace nanoFramework.TestFramework
{
/// <summary>
/// To skip a test, raise this exception thru the Assert.SkipTest("some message");
/// To skip a test, raise this exception through the Assert.SkipTest("some message");
/// </summary>
public class SkipTestException : Exception
{
/// <summary>
/// Initializes a new instance of the SkipTestException class.
/// </summary>
public SkipTestException()
: base()
{ }

/// <summary>
/// Initializes a new instance of the SkipTestException class with a specified error message.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public SkipTestException(string message)
: base(message)
{ }

/// <summary>
/// Initializes a new instance of the SkipTestException class with a specified error message
/// and a reference to the inner SkipTestException that is the cause of this exception.
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="innerException"></param>
public SkipTestException(string message, Exception innerException)
: base(message, innerException)
public SkipTestException(string message = null, Exception innerException = null) : base(message, innerException)
{ }
}
}