Skip to content

Commit

Permalink
F Add MultipleOfThree Action
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyzxs committed Dec 8, 2021
1 parent c6e5bff commit aed4be2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions TddLikeYouMeanIt/FizzBuzzTests.cs
Expand Up @@ -105,5 +105,28 @@ public Answer Transform(int source)

return new Default_RuleEvalAction().Act(turnCount);
}

public sealed class MultipleOfThree_RuleEvalAction : IRuleEvalAction
{
private readonly IRule _rule;
private readonly IRuleEvalAction _nextAction;

public MultipleOfThree_RuleEvalAction(IRuleEvalAction nextAction) :this(new MultipleOfThreeRule(), nextAction){}

private MultipleOfThree_RuleEvalAction(IRule rule, IRuleEvalAction nextAction)
{
_rule = rule;
_nextAction = nextAction;
}

public Answer Act(TurnCount turnCount)
{
if (ShouldHandle(turnCount)) return new FizzAnswer();

return _nextAction.Act(turnCount);
}

private bool ShouldHandle(TurnCount turnCount) => _rule.Matches(turnCount);
}
}
}

0 comments on commit aed4be2

Please sign in to comment.