NConstraints v1.1.1 Released Now Targets .NET Standard 2.0

I’m happy to announce that NConstraints v1.1.1 has been released! This release updates the NuGet package from .NET Standard 1.6 to 2.0 and should work with all versions of NUnit 3.

You can install NConstraints via the dotnet command line:

dotnet add package SaturdayMP.NConstraints --version 1.1.1

Other install options can be found here.

NConstraints currently only has one constraint called EquivalentPropertyWiseTo. It checks if all the property values on two objects are the same. Instead of writting:

[Test]
public void TestObjectsTheSame()
{
  var expected = new ExpectedClass() { ValueOne = 1, ValueTwo = "Blah", ValueThree = 33 };

  var actual = MethodBeingTested();
   
  Assert.That(expected.ValueOne, Is.EqualTo(actual.ValueOne));
  Assert.That(expected.ValueTwo, Is.EqualTo(actual.ValueTwo));
  Assert.That(expected.ValueThree, Is.EqualTo(actual.ValueThree));
}

You can write:

[Test]
public void TestObjectsTheSame()
{
  var expected = new ExpectedClass() { ValueOne = 1, ValueTwo = "Blah" };

  var actual = MethodBeingTested();
   
  Assert.That(expected, Is.EquivalentPropertyWiseTo(actual));
}

You can find more details on the NConstraints GitHub page. If you have any questions, notice a bug, or have improvements please let me know by:

P.S. – You can ignore the v.1.1.0 release. I accidently made NConstraints only compatible with NUnit 3.13.3 or higher instead of all NUnit 3.* versions.

This entry was posted in Uncategorized. Bookmark the permalink.