예제 #1
0
        public void WhenGameIsNotCompleteAndTryingToStartAnotherGameShouldThrow()
        {
            var set  = new Set();
            var game = set.AddGame();

            game.ScoreP1();

            Assert.Throws <ApplicationException>(() => set.AddGame(), "Cannot start a game while another game is in progress.");
        }
예제 #2
0
        public void WhenTryToAddGameToCompletedSetShouldThrow()
        {
            var set = new Set();

            for (int i = 0; i < NumberGamesToWin; i++)
            {
                var game = set.AddGame();
                for (int j = 0; j < 4; j++)
                {
                    game.ScoreP1();
                }
            }
            Assert.Throws <ApplicationException>(() => set.AddGame(), "Cannot add a game. Set is complete.");
        }
예제 #3
0
        public void When12GamesPlayedWithSixSixScoreThenShouldBeTieBreak()
        {
            var set = new Set();

            for (int i = 0; i < NumberGamesToWin; i++)
            {
                var game = set.AddGame();
                for (int j = 0; j < 4; j++)
                {
                    game.ScoreP1();
                }
                var game1 = set.AddGame();
                for (int j = 0; j < 4; j++)
                {
                    game1.ScoreP2();
                }
            }
            Assert.IsTrue(set.IsTiebreak());
        }
예제 #4
0
        public void Correctly_outputs_1_nil()
        {
            var set  = new Set(Player.One);
            var game = set.AddGame(Player.One);

            game.Points.Add(Player.One);
            game.Points.Add(Player.One);
            game.Points.Add(Player.One);
            game.Points.Add(Player.One);

            set.Score(Player.One).Should().Be("1-0");
        }
예제 #5
0
        public void Correctly_outputs_3_all()
        {
            var set = new Set(Player.One);

            for (int i = 0; i < 3; i++)
            {
                var game = set.AddGame(Player.One);

                game.Points.Add(Player.One);
                game.Points.Add(Player.One);
                game.Points.Add(Player.One);
                game.Points.Add(Player.One);

                game = set.AddGame(Player.One);

                game.Points.Add(Player.Two);
                game.Points.Add(Player.Two);
                game.Points.Add(Player.Two);
                game.Points.Add(Player.Two);
            }

            set.Score(Player.One).Should().Be("3-3");
        }