Пример #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 TestBownling271()
        {
            int    shouldBeValue  = 271;
            string shouldBeString = "X,X,X,X,X,X,X,X,X,1/X";

            Bowling game = new Bowling();

            game.AddStrike().AddStrike().AddStrike().AddStrike().AddStrike().AddStrike().AddStrike().AddStrike().AddStrike().AddFrameExtra(1, 9, 10);

            int score = game.CalculateScore();

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

            string visual = game.ToString();

            Assert.AreEqual <string>(shouldBeString, visual);
        }
Пример #3
0
        public void TestBownling20()
        {
            int    shouldBeValue  = 20;
            string shouldBeString = "00,00,00,00,00,00,00,00,00,X1/";

            Bowling game = new Bowling();

            game.AddMiss().AddMiss().AddMiss().AddMiss().AddMiss().AddMiss().AddMiss().AddMiss().AddMiss().AddFrameExtra(10, 1, 9);

            int score = game.CalculateScore();

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

            string visual = game.ToString();

            Assert.AreEqual <string>(shouldBeString, visual);
        }
Пример #4
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);
        }
Пример #5
0
        public void TestBownling10AsSpare()
        {
            int    shouldBeValue  = 10;
            string shouldBeString = "5/";

            Bowling game = new Bowling();

            game.AddSpare(5);

            int score = game.CalculateScore();

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

            string visual = game.ToString();

            Assert.AreEqual <string>(shouldBeString, visual);
        }
 public void Setup()
 {
     bowling = new Bowling();
 }
Пример #7
0
 public BowlingTest() {
     bowling = new Bowling();
 }