Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }