public void ShorterStringShouldNeverViolateConstraint() { // Fixture setup const uint maxLength = 20; var generator = from s in Arb.Generate <string>() where s != null && s.Length <= maxLength select s; var constraint = new MaxStringLengthConstraint(maxLength); // Exercise system and verify outcome Prop.ForAll( generator.ToArbitrary(), s => constraint.Check(s).Violated.Should().BeFalse()) .QuickCheckThrowOnFailure(); }
public void LongerStringShouldAlwaysViolateConstraint() { // Fixture setup const uint maxLength = 20; var generator = from s in Arb.Generate <string>() where s != null && s.Length > maxLength select s; var constraint = new MaxStringLengthConstraint(maxLength); // Exercise system and verify outcome Prop.ForAll(generator.ToArbitrary(), s => { var result = constraint.Check(s); result.Violated.Should().BeTrue(); result.Message.Should().Be($"String length must be smaller or equal '{maxLength}' but '{s.Length}'."); }).QuickCheckThrowOnFailure(); }