Skip to content

Commit

Permalink
deprecate Is, add Matches (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilasquared authored and theramis committed Jan 11, 2021
1 parent cb8c24f commit f8b66ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion project/Snapper.Nunit/SnapConstraint.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using NUnit.Framework.Constraints;
using Snapper.Core;

Expand All @@ -14,6 +14,7 @@ public static EqualToSnapshotConstraint EqualToSnapshot(this ConstraintExpressio
}
}

[Obsolete("Snapper.Nunit.Is will be removed in a future release. Please use Snapper.Nunit.Matches")]
public class Is : NUnit.Framework.Is
{
public static EqualToSnapshotConstraint EqualToSnapshot()
Expand All @@ -32,6 +33,19 @@ public static EqualToSnapshotConstraint EqualToChildSnapshot(string childSnapsho
}
}

public class Matches
{
public static EqualToSnapshotConstraint Snapshot()
{
return new EqualToSnapshotConstraint();
}

public static EqualToSnapshotConstraint ChildSnapshot(string snapshotName)
{
return new EqualToSnapshotConstraint(snapshotName);
}
}

public class EqualToSnapshotConstraint : Constraint
{
private readonly SnapshotId _snapshotId;
Expand Down
6 changes: 3 additions & 3 deletions project/Tests/Snapper.Nunit.Tests/NUnitSnapperTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using Newtonsoft.Json.Linq;
using NUnit.Framework;

Expand All @@ -14,7 +14,7 @@ public void TestIfStoredSnapshotIsMatching()
{
{"TestProperty", "TestValue"}
};
Assert.That(actual, Is.EqualToSnapshot());
Assert.That(actual, Matches.Snapshot());
}

[Test]
Expand All @@ -25,7 +25,7 @@ public void TestIfNamedStoredSnapshotIsMatching()
{
{"TestProperty2", "TestValue2"}
};
Assert.That(actual, Is.EqualToChildSnapshot("ChildSnapshot"));
Assert.That(actual, Matches.ChildSnapshot("ChildSnapshot"));
}
}
}

0 comments on commit f8b66ec

Please sign in to comment.