Exemple #1
0
        public void NumericStringShouldNeverViolateConstraint()
        {
            // Fixture setup
            var generator = from n in Arb.Generate <uint>() select n.ToString();

            var constraint = new RegexConstraint(pattern);

            // Exercise system and verify outcome
            Prop.ForAll(
                generator.ToArbitrary(),
                s => constraint.Check(s).Violated.Should().BeFalse())
            .QuickCheckThrowOnFailure();
        }
Exemple #2
0
        public void NotNumericStringStringShouldAlwaysViolateConstraint()
        {
            // Fixture setup
            var generator  = from s in Arb.Generate <string>() where s != null && !s.Any(char.IsDigit) select s;
            var constraint = new RegexConstraint(pattern);

            // Exercise system and verify outcome
            Prop.ForAll(generator.ToArbitrary(), s =>
            {
                var result = constraint.Check(s);
                result.Violated.Should().BeTrue();
                result.Message.Should().Be($"String does not match pattern '{pattern}'.");
            }).QuickCheckThrowOnFailure();
        }