Exemplo n.º 1
0
        public void Awards2500Pts()
        {
            var diceProvider = new MockDiceProvider(new DieRoll[] { DieRoll.Five, DieRoll.Five, DieRoll.Five, DieRoll.Two, DieRoll.Two });
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();
            var result       = diceProc.CheckRollResult(roll);

            Assert.True(result.Points == _points, $"Awarded {result.Points} instead of {_points}.");
        }
Exemplo n.º 2
0
        public void FakeDiceRollFactoryReturnsArrayOfDice()
        {
            var diceSet  = FakeDiceRollFactory.GetSetOfRolls(DieRoll.Five, 3);
            var fakeDice = new MockDiceProvider(diceSet).RollAllFiveDice();

            Assert.True(diceSet.Length == 5);
            Assert.True(diceSet.Take(3).All(x => x == DieRoll.Five));
            Assert.True(diceSet.Skip(3).All(x => x != DieRoll.Five));
            Assert.True(fakeDice.All(x => ((int)x).Between(1, 6)));
        }
Exemplo n.º 3
0
        public void DoesNotOccurWhenRollingAPair()
        {
            var diceProvider = new MockDiceProvider(new DieRoll[] { DieRoll.Five, DieRoll.Five, DieRoll.Six, DieRoll.One, DieRoll.Two });
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.DiceCombination != _combination, $"Expected combination different from {_combination}, but got {result.DiceCombination} instead.");
        }
Exemplo n.º 4
0
        public void DoesNotOccurWhenRollingFourOrMoreOfTheSameDie(DieRoll[] dice, DiceCombination diceCombination)
        {
            var diceProvider = new MockDiceProvider(dice);
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.DiceCombination == diceCombination, $"Expected {diceCombination} combination, but got {result.DiceCombination} instead.");
        }
Exemplo n.º 5
0
        public void OccursWhenRollingThreeOfTheSameDie()
        {
            var diceProvider = new MockDiceProvider(new DieRoll[] { DieRoll.Five, DieRoll.Five, DieRoll.Five, DieRoll.One, DieRoll.Two });
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.DiceCombination == _combination, $"Expected {_combination} combination, but got {result.DiceCombination} instead.");
        }
Exemplo n.º 6
0
        public void Awards300Pts()
        {
            IDiceProvider  diceProvider = new MockDiceProvider(dice);
            IDiceGenerator diceGen      = new DiceRollGenerator(diceProvider);
            RulesProcessor rules        = new RulesProcessor(diceProvider);
            var            roll         = diceGen.Roll();

            var result = rules.CheckRollResult(roll);

            Assert.True(result.Points == _points);
        }
Exemplo n.º 7
0
        public void OccursWhenRollingTwoOnesAndTwoFives()
        {
            IDiceProvider  diceProvider = new MockDiceProvider(dice);
            IDiceGenerator diceGen      = new DiceRollGenerator(diceProvider);
            RulesProcessor rules        = new RulesProcessor(diceProvider);
            var            roll         = diceGen.Roll();

            var result = rules.CheckRollResult(roll);

            Assert.True(result.DiceCombination == _combination);
        }
Exemplo n.º 8
0
        public void OnlyHappensWhenRollingTwoThroughSix(DieRoll[] dice, bool isHighStraight)
        {
            var diceProvider = new MockDiceProvider(dice);
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True((result.DiceCombination == _combination) == isHighStraight, $"Expected {_combination} combination, but got {result.DiceCombination} instead.");
        }
Exemplo n.º 9
0
        public void OccurForNonOneOrNonFiveDice(DieRoll[] dice)
        {
            IDiceProvider  diceProvider = new MockDiceProvider(dice);
            IDiceGenerator diceGen      = new DiceRollGenerator(diceProvider);
            RulesProcessor rules        = new RulesProcessor(diceProvider);
            var            roll         = diceGen.Roll();

            var result = rules.CheckRollResult(roll);

            Assert.True(result.DiceCombination == _combination);
        }
Exemplo n.º 10
0
        public void IsOnlyPossibleIfThereAreFourOfTheSameDie()
        {
            var diceProvider = new MockDiceProvider(_dice);
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.Points == _points, $"Awarded {result.Points} instead of {_points}.");
        }
Exemplo n.º 11
0
        public void Awards1000Pts()
        {
            var diceProvider = new MockDiceProvider(_dice);
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.DiceCombination == _combination, $"Expected {_combination} combination, but got {result.DiceCombination} instead.");
        }
Exemplo n.º 12
0
        public void OccursWhenTwoDiceAreTheSameAndThreeDifferentDiceAreTheSame(DieRoll[] dice, bool isFullHouse)
        {
            var diceProvider = new MockDiceProvider(dice);
            var diceProc     = new RulesProcessor(diceProvider);
            var diceGen      = new DiceRollGenerator(diceProvider);
            var roll         = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True((result.DiceCombination == _combination) == isFullHouse, $"Expected {_combination} combination, but got {result.DiceCombination} instead.");
        }
Exemplo n.º 13
0
        public void Awards500PtsIfThreeFivesAreRolled()
        {
            int expectedPoints = 500;
            var diceProvider   = new MockDiceProvider(new DieRoll[] { DieRoll.Five, DieRoll.Five, DieRoll.Five, DieRoll.Three, DieRoll.Two });
            var diceProc       = new RulesProcessor(diceProvider);
            var diceGen        = new DiceRollGenerator(diceProvider);
            var roll           = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.Points == expectedPoints, $"Awarded {result.Points} instead of {expectedPoints}.");
        }
Exemplo n.º 14
0
        public void Awards100PtsMultipliedByTheDieValue()
        {
            int expectedPoints = _pointsBase * 5;
            var diceProvider   = new MockDiceProvider(new DieRoll[] { DieRoll.Five, DieRoll.Five, DieRoll.Five, DieRoll.One, DieRoll.Two });
            var diceProc       = new RulesProcessor(diceProvider);
            var diceGen        = new DiceRollGenerator(diceProvider);
            var roll           = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.Points == expectedPoints, $"Awarded {result.Points} instead of {expectedPoints}.");
        }
Exemplo n.º 15
0
        public void IsNotAwardedIfAtLeastOneDieIsDifferent()
        {
            var diceProvider = new MockDiceProvider(_dice)
            {
                DiceFive = (DieRoll)1
            };
            var diceProc = new RulesProcessor(diceProvider);
            var diceGen  = new DiceRollGenerator(diceProvider);
            var roll     = diceGen.Roll();

            var result = diceProc.CheckRollResult(roll);

            Assert.True(result.DiceCombination != _combination, $"Expected non Five of a kind combination, but got {result.DiceCombination} instead.");
        }