public void ShouldBuildIntegerRuleOnRequest()
        {
            var integerRuleBuilder = new IntegerRuleBuilder();

            var rule = integerRuleBuilder.Build();

            rule.GetType().Should().Be <IntegerRule>();
            rule.GetType().Should().BeAssignableTo <IRule>();
        }
        public void ShouldBuildDefaultIntegerRuleOnRequestWhichHasNoSideEfects()
        {
            var integerRuleBuilder = new IntegerRuleBuilder();

            var rule = integerRuleBuilder.Build();

            Action act = () => rule.Apply(Any.Integer());

            act.Should().NotThrow();
        }
Пример #3
0
        public static IRule Create(IOutputBuilder outputBuilder)
        {
            var by15RuleBuilder    = new DivisibleBy15RuleBuilder().RedirectResultTo(outputBuilder);
            var by3RuleBuilder     = new DivisibleBy3RuleBuilder().RedirectResultTo(outputBuilder);
            var by5RuleBuilder     = new DivisibleBy5RuleBuilder().RedirectResultTo(outputBuilder);
            var integerRuleBuilder = new IntegerRuleBuilder().RedirectResultTo(outputBuilder);
            var endOfChain         = new NullRule();

            integerRuleBuilder.ContinueWith(endOfChain);
            by5RuleBuilder.BreakIfApplied().ContinueWith(integerRuleBuilder.Build());
            by3RuleBuilder.BreakIfApplied().ContinueWith(by5RuleBuilder.Build());
            by15RuleBuilder.BreakIfApplied().ContinueWith(by3RuleBuilder.Build());

            return(by15RuleBuilder.Build());
        }