コード例 #1
0
        public void MultiplesOfTheSameDiceCanBeAdded()
        {
            var cup = new Cup();

            cup.AddDice(
                Die.GetDice(DiceSides.d6, 4)
                );
            Assert.AreEqual(new Die[] { Die.D6(), Die.D6(), Die.D6(), Die.D6() }, cup.Dice);
        }
コード例 #2
0
        public void ResultsCanBeFilteredByTakingTheHighestNumberOfDice()
        {
            //For stats we frequently roll 4d6 and want the top 3...
            var cup = new Cup(Die.GetDice(DiceSides.d6, 4));

            cup.Roll();
            var sumTop3 = cup.SumTop(3);

            var manualSum = 0;
            var lowest    = 100;

            foreach (var d in cup.Dice)
            {
                manualSum += d.LastRoll;
                if (d.LastRoll < lowest)
                {
                    lowest = d.LastRoll;
                }
            }

            Assert.AreEqual(manualSum - lowest, sumTop3);
        }
コード例 #3
0
        public void CreateAnArrayOfDiceByPassingANumberIntoTheHelperMethod()
        {
            var diceArray = Die.GetDice(DiceSides.d12, 4);

            Assert.AreEqual(new Die[] { Die.D12(), Die.D12(), Die.D12(), Die.D12() }, diceArray);
        }
コード例 #4
0
        public void CupCanBeCreatedWithArrayOfDice()
        {
            var cup = new Cup(Die.GetDice(DiceSides.d6, 4));

            Assert.AreEqual(new Die[] { Die.D6(), Die.D6(), Die.D6(), Die.D6() }, cup.Dice);
        }