/NUnit.Asserts

Primary LanguageC#MIT LicenseMIT

NUnit.Asserts

Set of simple libraries with common (more or less) asserts that makes Your tests more DRY!

NuGets

Install-Package NUnit.Asserts.Microsoft.Owin.Security
Install-Package NUnit.Asserts.Compare

NUnit.Asserts.Microsoft.Owin.Security

Asserts that help to examine ClaimsIdentity object

  • Checking ClaimsIdentity
ClaimsIdentityAssert.ContainsClaim(ClaimTypes.Role, "user", context.Ticket.Identity);
ClaimsIdentityAssert.DoesNotContainClaim(ClaimTypes.Role, "user", context.Ticket.Identity);

NUnit.Asserts.Compare

Couple of simple Nunit asserts that compare given objects using https://www.nuget.org/packages/CompareNETObjects/

  • Compare objects
Assert.That(actualObject, Compares.To(expected));
  • Assert object is contained in collection
Assert.That(actualObject, Compares.ToAnyIn(list));
  • Ignore property
Assert.That(actualObject, Compares.To(expected).IgnoreProperty(p => p.Some));
  • Ignore type checking
Assert.That(actualObject, Compares.To(expected).WithoutTypeChecking());
  • Compare objects with types check:
CompareAssert.AreEqual(expectedObject, actualObject);
  • Compare objects without types check:
CompareAssert.AreEquivalent(expectedObject, actualObject);
  • Compare objects without specified properties:
CompareAssert.AreEqual(expectedObject, actualObject, p => p.PropertyToIgnore, p => p.OtherPropertyToIgnore);
CompareAssert.AreEquivalent(expectedObject, actualObject, p => p.PropertyToIgnore, p => p.OtherPropertyToIgnore);
CompareAssert.AreEqual(expectedObject, actualObject, "PropertyToIgnore", "OtherPropertyToIgnore");
CompareAssert.AreEquivalent(expectedObject, actualObject, "PropertyToIgnore", "OtherPropertyToIgnore");