Example #1
0
        public void When_Pins_Knocked_Number_Is_Invalid_Then_ThrowError()
        {
            // Arrange
            Game game = new Game();

            // Assert & Act
            Assert.Throws <ArgumentException>(() => game.Roll(-8));
        }
Example #2
0
        public void When_Rolling_Ball_Then_Save_Pins_Knocked_Number()
        {
            // Arrange
            Game game = new Game();

            // Act
            game.Roll(8);

            // Assert
            game.score.Should().Be(8);
        }
Example #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);
        }
Example #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);
        }
Example #5
0
 public void OneRollTest(int pins)
 {
     game.Roll(pins);
 }
Example #6
0
 public void AddBallToScore()
 {
     game.Roll(3);
     Assert.AreEqual(3, game.Score);
 }
Example #7
0
        public void NegativePinsNotAllowed(int pins)
        {
            Action act = () => game.Roll(pins);

            Assert.Throws <ArgumentException>(act);
        }