예제 #1
0
        public void TestBownlingUnder10()
        {
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < (10 - i); j++)
                {
                    int           shouldBeValue  = 0;
                    StringBuilder shouldBeString = new StringBuilder();
                    Bowling       game           = new Bowling();

                    for (int k = 0; k < 10; k++)
                    {
                        shouldBeValue += i + j;
                        shouldBeString.Append(i);
                        shouldBeString.Append(j);
                        shouldBeString.Append(",");
                        game.AddFrame(i, j);
                    }
                    // Remove last ","
                    shouldBeString.Remove(shouldBeString.Length - 1, 1);

                    int score = game.CalculateScore();
                    Assert.AreEqual <int>(shouldBeValue, score);

                    string visual = game.ToString();
                    Assert.AreEqual <string>(shouldBeString.ToString(), visual);
                }
            }
        }
예제 #2
0
        public void TestBownling15()
        {
            int    shouldBeValue  = 15;
            string shouldBeString = "11,1/,11";

            Bowling game = new Bowling();

            game.AddFrame(1, 1).AddSpare(1).AddFrame(1, 1);

            int score = game.CalculateScore();

            Assert.AreEqual <int>(shouldBeValue, score);

            string visual = game.ToString();

            Assert.AreEqual <string>(shouldBeString, visual);
        }