public void NonWhiteSpaceStringStringShouldNeverViolateConstraint() { // Fixture setup var generator = from s in Arb.Generate <string>() where !string.IsNullOrWhiteSpace(s) select s; var constraint = new NotNullOrWhiteSpaceStringConstraint(); // Exercise system and verify outcome Prop.ForAll( generator.ToArbitrary(), s => constraint.Check(s).Violated.Should().BeFalse()) .QuickCheckThrowOnFailure(); }
public void WhiteSpaceStringConstraintStringShouldAlwaysViolateConstraint() { // Fixture setup var generator = from s in Arb.Generate <string>() where string.IsNullOrWhiteSpace(s) select s; var constraint = new NotNullOrWhiteSpaceStringConstraint(); // Exercise system and verify outcome Prop.ForAll(generator.ToArbitrary(), s => { var result = constraint.Check(s); result.Violated.Should().BeTrue(); result.Message.Should().Be("String must not be null or white space."); }).QuickCheckThrowOnFailure(); }