Пример #1
0
 public void ShouldBeCorrectSum(int actual, int[] expected)
 {
     var game = new BowlingGame();
     for (int i = 0; i < expected.Length; i++ )
     {
         game.Turn(expected[i]);
     }
     Assert.AreEqual(actual, game.ScoreGame());
 }
Пример #2
0
        public void BowlingGame_Rolls_CorrectCurrentScoreCalculated()
        {
            //Arrange
            var game = new BowlingGame();
            List <(int Roll, int Score)> rollsWithCurrentScore = new List <(int Roll, int Score)>
            {
                (1, 1), (4, 5), (4, 9), (5, 14), (6, 20), (4, 24), (5, 34),
                (5, 39), (10, 59), (0, 59), (1, 61), (7, 68), (3, 71),
                (6, 83), (4, 87), (10, 107), (2, 111), (8, 127), (6, 133)
            };

            //Act
            foreach ((int Roll, int Score) in rollsWithCurrentScore)
            {
                game.Roll(Roll);
                Assert.Equal(Score, game.TotalScore);
            }
        }
Пример #3
0
        public void BowlingGame_GameFinishedAndRoll_ExceptionThrown()
        {
            //Arrange
            var game  = new BowlingGame();
            var rolls = new List <int> {
                10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
            };

            game.RollMany(rolls);
            var expectedMessage = "The game is finished!";

            //Act
            Action act = () => game.Roll(5);

            //Assert
            act.Should().Throw <ArgumentOutOfRangeException>()
            .And
            .Message.Should().ContainEquivalentOf(expectedMessage);
        }
Пример #4
0
        public void GivenGameIsPlayed_ThenReturnExpectedScore(int[] throws, int expectedScore)
        {
            var actualScore = BowlingGame.CalculateScore(throws);

            Assert.That(actualScore, Is.EqualTo(expectedScore));
        }
Пример #5
0
 protected void setupGame()
 {
     game = new BowlingGame();
 }
Пример #6
0
 public BowlingGameTest()
 {
     bowlingGame = new BowlingGame();
 }