Beispiel #1
0
        public void The_failure_message_returned_is_the_first_to_fail()
        {
            var first  = new ArgumentsRule(o => "first error");
            var second = new ArgumentsRule(o => "second error");

            var appliedOption = new AppliedOption(Create.Option("-x", ""));

            first.And(second).Validate(appliedOption).Should().Be("first error");
        }
Beispiel #2
0
        public void Composed_rule_results_are_equivalent_when_one_is_successful_and_the_other_fails()
        {
            var fail    = new ArgumentsRule(o => "fail");
            var succeed = new ArgumentsRule(o => "fail");

            var appliedOption = new AppliedOption(Create.Option("-x", ""));

            fail.And(succeed).Validate(appliedOption).Should().Be("fail");
            succeed.And(fail).Validate(appliedOption).Should().Be("fail");
        }
Beispiel #3
0
        public void Later_rules_are_not_evaluated()
        {
            var secondRuleWasCalled = false;
            var first  = new ArgumentsRule(o => "first error");
            var second = new ArgumentsRule(o =>
            {
                secondRuleWasCalled = true;
                return("second error");
            });

            var appliedOption = new AppliedOption(Create.Option("-x", ""));

            first.And(second).Validate(appliedOption);

            secondRuleWasCalled.Should().BeFalse();
        }