public void DiceCalculator_Threes_2ReturnsValidAndScoreOf6() { //arrange var rules = new List <Func <byte[], bool> >(); Func <byte[], int> scoreFormula; byte valueToCheck = 3; byte minimumCount = 1; scoreFormula = DiceScoringFormulas.DiceSumOfSpecificNumber(valueToCheck); rules.Add(DiceValidations.DiceMustHaveCount(5)); rules.Add(DiceValidations.DiceMustHaveValues1To6()); rules.Add(DiceValidations.DiceMustContain(valueToCheck)); rules.Add(DiceValidations.DiceMustHaveCountOfACertainValue(valueToCheck, minimumCount)); var calculator = new DiceCalculator(rules, scoreFormula, "Threes", "The sum of the dice with the number 3"); //act var results = calculator.Calculate(GetDiceByteArray(1, 3, 2, 4, 3)); //assert) Assert.IsTrue(results.IsValid && results.Score == 6); }
public void DiceCalculator_Aces_ReturnsSumOf1s(byte valueToCheck, byte[] bytes, int expected) { //arrange var rules = new List <Func <byte[], bool> >(); var scoreFormula = DiceScoringFormulas.DiceSumOfSpecificNumber(valueToCheck); rules.Add(DiceValidations.DiceAlwaysValid()); var calculator = new DiceCalculator(rules, scoreFormula, "Aces", "The sum of the dice with the number 1"); //act var results = calculator.Calculate(bytes); //assert) Assert.IsTrue(results.IsValid, "Results should have been valid."); Assert.IsTrue(results.Score == expected, $"Score was expected to be {expected} but was {results.Score} instead."); }