Not Constraint
NotConstraint
reverses the effect of another constraint. If the base constraint fails, NotConstraint succeeds. If the
base constraint succeeds, NotConstraint fails.
Constructor
NotConstraint()
Syntax
Is.Not...
Examples of Use
public class Person
{
public string Name { get; set; } = "";
public int Age { get; set; }
public string Email { get; set; } = "";
}
[Test]
public void PropertyConstraint_Examples()
{
var person = new Person { Name = "John", Age = 25, Email = "john@example.com" };
Assert.That(person, Has.Property("Name").EqualTo("John"));
Assert.That(person, Has.Property("Age").GreaterThan(18));
Assert.That(person, Has.Property("Email").Contains("@"));
}