Пример #1
0
        public void ShouldProduceNothingOnOutputWhenApplyForIntegerNotDivisibleBy3()
        {
            var input         = Any.IntegerNotDivisibleBy(3);
            var outputBuilder = Substitute.For <IOutputBuilder>();
            var rule          = new DivisibleBy3Rule(false, Any.InstanceOf <IRule>(), outputBuilder);

            rule.Apply(input);

            outputBuilder.DidNotReceive().Append(Arg.Any <string>());
        }
Пример #2
0
        public void ShouldProduceFizzOnOutputWhenApplyForIntegerDivisibleBy3()
        {
            var input         = Any.IntegerDivisibleBy(3);
            var outputBuilder = Substitute.For <IOutputBuilder>();
            var rule          = new DivisibleBy3Rule(false, Any.InstanceOf <IRule>(), outputBuilder);

            rule.Apply(input);

            outputBuilder.Received().Append("Fizz");
        }
Пример #3
0
        public void ShouldNotCallSuccessorWhenApplyIsCalledAndIsBreakable()
        {
            var input         = Any.IntegerDivisibleBy(3);
            var outputBuilder = Substitute.For <IOutputBuilder>();
            var successor     = Substitute.For <IRule>();
            var rule          = new DivisibleBy3Rule(true, successor, outputBuilder);

            rule.Apply(input);

            outputBuilder.Received().Append("Fizz");
            successor.DidNotReceive().Apply(input);
        }
Пример #4
0
        public void ShouldCallSuccessorWhenApplyIsCalledAndRuleDoesNotMatches()
        {
            var input         = Any.IntegerNotDivisibleBy(3);
            var successor     = Substitute.For <IRule>();
            var outputBuilder = Substitute.For <IOutputBuilder>();
            var rule          = new DivisibleBy3Rule(false, successor, outputBuilder);

            rule.Apply(input);

            outputBuilder.DidNotReceive().Append(Arg.Any <string>());
            successor.Received().Apply(input);
        }