Beispiel #1
0
        public void ConstantScoreGameTest(int pins)
        {
            RollDefinedNumberOfPins(20, pins);
            int score = game.Score();

            Assert.Equal(20 * pins, score);
        }
Beispiel #2
0
        public void TooFewRollsNotAllowed(int rollsCount)
        {
            Action act = () =>
            {
                int score = 0;
                for (int i = 0; i < rollsCount; i++)
                {
                    game.Roll(0);
                }
                score = game.Score();
            };

            Assert.Throws <NullReferenceException>(act);
        }
Beispiel #3
0
        public void Test_A_Last_Strike_Score()
        {
            //Arrange
            var game = new Game();

            var rollings = new List <int> {
                1, 4, 4, 5, 6, 4, 5, 5, 10, 0, 1, 7, 3, 6, 4, 10, 10, 10, 10
            };

            foreach (int pins in rollings)
            {
                game.Roll(pins);
            }

            //Act
            var result = game.Score();

            //Assert
            var actual   = result;
            var expected = 157;

            Console.WriteLine($@"Last Strike Score: {actual}");
            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        public void Test_Worst_Score()
        {
            //Arrange
            IGame game = new Game();

            var rollings = new List <int> {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            foreach (int pins in rollings)
            {
                game.Roll(pins);
            }

            //Act
            var result = game.Score();

            //Assert
            var actual   = result;
            var expected = 0;

            Console.WriteLine($@"Worst Score: {actual}");
            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
 public void gutterGame()
 {
     rollMany(20, 0);
     Assert.AreEqual(0, g.Score());
 }