Пример #1
0
        public void DiceTest()
        {
            //taking place of random # generater
            //Arrange
            var expectedValues = new List <int> {
                1, 2, 3, 4, 5
            };
            NotActuallyRandom random = new NotActuallyRandom(expectedValues);
            var expectedRollCount    = 1;

            //Act
            Dice yahtzeeDice = new Dice(random);


            //Assert
            for (int index = 0; index < expectedValues.Count; index++)
            {
                Assert.AreEqual(expectedValues[index], yahtzeeDice.GetDieValue(index + 1));
            }
            Assert.IsFalse(yahtzeeDice.HoldDie1);
            Assert.IsFalse(yahtzeeDice.HoldDie2);
            Assert.IsFalse(yahtzeeDice.HoldDie3);
            Assert.IsFalse(yahtzeeDice.HoldDie4);
            Assert.IsFalse(yahtzeeDice.HoldDie5);
            Assert.AreEqual(expectedRollCount, yahtzeeDice.RollCount);
        }
Пример #2
0
        public void RollTest()
        {
            var expectedValues = new List <int> {
                1, 2, 3, 4, 5
            };
            NotActuallyRandom random = new NotActuallyRandom(expectedValues);
            var expectedRollCount    = 1;

            // Act
            Dice yahtzeeDice = new Dice(random);

            yahtzeeDice.Roll();

            // Asssert
            for (int index = 0; index < expectedValues.Count; index++)
            {
                Assert.AreEqual(expectedValues[index], yahtzeeDice.GetDieValue(index + 1));
            }
        }
Пример #3
0
        public void ScoreCardTest()
        {
            // Arrange
            var expectedValues = new List <int> {
                1, 2, 3, 4, 5
            };
            NotActuallyRandom random = new NotActuallyRandom(expectedValues);
            var dice = new Dice(random);
            var expectedOnesScore      = 1;
            var expectedTwosScore      = 2;
            var expectedThreesScore    = 3;
            var expectedFoursScore     = 4;
            var expectedFivesScore     = 5;
            var expectedSixesScore     = 6;
            var expectedFullHouseScore = 0;


            // Act
            dice.Roll();
            var testScorecard = new ScoreCard(dice);

            testScorecard.CalculateOnes(dice);
            testScorecard.CalculateTwos(dice);
            testScorecard.CalculateThrees(dice);
            testScorecard.CalculateFours(dice);
            testScorecard.CalculateFives(dice);
            testScorecard.CalculateSixes(dice);


            // Assert
            Assert.AreEqual(expectedOnesScore, testScorecard.Ones);
            Assert.AreEqual(expectedTwosScore, testScorecard.Twos);
            Assert.AreEqual(expectedThreesScore, testScorecard.Threes);
            Assert.AreEqual(expectedFoursScore, testScorecard.Fours);
            Assert.AreEqual(expectedFivesScore, testScorecard.Fives);
            Assert.AreEqual(expectedSixesScore, testScorecard.Sixes);



            Assert.AreEqual(expectedFullHouseScore, testScorecard.FullHouse);
        }