コード例 #1
0
ファイル: DiceGenerator.cs プロジェクト: kapros/GreedGame
        public void RerollsDiceOne()
        {
            var sut      = new DiceRollGenerator(new DiceProvider());
            var diceRoll = sut.Roll();

            var newRoll = sut.RerollDiceOne(diceRoll);

            Assert.True(diceRoll != newRoll);
        }
コード例 #2
0
ファイル: RollingFullHouse.cs プロジェクト: kapros/GreedGame
        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}.");
        }
コード例 #3
0
        public void IsOnlyPossibleWhenAllDiceAreTheSame()
        {
            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.");
        }
コード例 #4
0
        public void Awards1500Pts()
        {
            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}.");
        }
コード例 #5
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);
        }
コード例 #6
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}.");
        }
コード例 #7
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.");
        }
コード例 #8
0
ファイル: RollingFullHouse.cs プロジェクト: kapros/GreedGame
        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.");
        }
コード例 #9
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.");
        }
コード例 #10
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.");
        }
コード例 #11
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.");
        }
コード例 #12
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.");
        }
コード例 #13
0
ファイル: RollingTwoPair.cs プロジェクト: kapros/GreedGame
        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);
        }
コード例 #14
0
ファイル: RollingTwoPair.cs プロジェクト: kapros/GreedGame
        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);
        }
コード例 #15
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}.");
        }
コード例 #16
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}.");
        }
コード例 #17
0
        public void ShouldCreateNumbersWithin1And6ForAllDice()
        {
            var listOfRolls = new List <int[]>();
            var diceGen     = new DiceRollGenerator(new DiceProvider());

            for (int i = 0; i < 100; i++)
            {
                listOfRolls.Add(diceGen.Roll().AllDice.ToIntArray());
            }

            Assert.True(listOfRolls.All(x => x.All(y => y >= _min && y <= _max)));
        }
コード例 #18
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.");
        }
コード例 #19
0
        public void BeRerolledWithMoverThan5Dice(int noOfDice)
        {
            var diceGen = new DiceRollGenerator(new MockDiceProvider(_diceRoll.AllDice));

            Assert.Throws <IndexOutOfRangeException>(() => diceGen.RerollMany(_diceRoll, Enumerable.Range(1, noOfDice).ToArray()));
        }
コード例 #20
0
        public void BeRerolledWith0Dice()
        {
            var diceGen = new DiceRollGenerator(new MockDiceProvider(_diceRoll.AllDice));

            Assert.Throws <IndexOutOfRangeException>(() => diceGen.RerollMany(_diceRoll, new int[0]));
        }
コード例 #21
0
ファイル: DiceGenerator.cs プロジェクト: kapros/GreedGame
        public void RollsFiveDice()
        {
            var sut = new DiceRollGenerator(new DiceProvider()).Roll();

            Assert.True(sut.AllDice.Length == 5);
        }