private static void ScorePoints(ITennisGame game, string playerName, int points)
 {
     for (var i = 0; i < points; i++)
     {
         game.WonPoint(playerName);
     }
 }
Esempio n. 2
0
 protected void scorePoints(ITennisGame game, string playerName, int points)
 {
     for (int i = 0; i < points; i++)
     {
         game.WonPoint(playerName);
     }
 }
 public void RealisticTennisGame(ITennisGame game)
 {
     String[] points =          {"player1", "player1", "player2", "player2", "player1", "player1"};
       String[] expected_scores = {"Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1"};
       for (int i = 0; i < 6; i++) {
     game.WonPoint(points[i]);
     Assert.AreEqual(expected_scores[i], game.GetScore());
       }
 }
Esempio n. 4
0
 public void RealisticTennisGame(ITennisGame game)
 {
     String[] points          = { "player1", "player1", "player2", "player2", "player1", "player1" };
     String[] expected_scores = { "Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1" };
     for (int i = 0; i < 6; i++)
     {
         game.WonPoint(points[i]);
         Assert.AreEqual(expected_scores[i], game.GetScore());
     }
 }
Esempio n. 5
0
 private void RealisticTennisGame(ITennisGame game)
 {
     string[] points         = { "player1", "player1", "player2", "player2", "player1", "player1" };
     string[] expectedScores = { "Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1" };
     for (var i = 0; i < 6; i++)
     {
         game.WonPoint(points[i]);
         Assert.AreEqual(expectedScores[i], game.CalculateScore());
     }
 }
Esempio n. 6
0
        private void Play(int ballsToPlayer1, int ballsToPlayer2, string expectedScore)
        {
            tennis = new TennisGame_Dirty();

            for (int i = 0; i < ballsToPlayer1; i++)
            {
                tennis.Player1WinsTheBall();
            }

            for (int i = 0; i < ballsToPlayer2; i++)
            {
                tennis.Player2WinsTheBall();
            }

            Assert.Equal(expectedScore, tennis.PrintScore());
        }
Esempio n. 7
0
        private void CheckAllScores(ITennisGame game)
        {
            var highestScore = Math.Max(player1Score, player2Score);

            for (var i = 0; i < highestScore; i++)
            {
                if (i < player1Score)
                {
                    game.WonPoint("player1");
                }
                if (i < player2Score)
                {
                    game.WonPoint("player2");
                }
            }
            Assert.AreEqual(expectedScore, game.CalculateScore());
        }
Esempio n. 8
0
        public void CheckAllScores(ITennisGame game)
        {
            var highestScore = Math.Max(_player1Score, _player2Score);

            for (var i = 0; i < highestScore; i++)
            {
                if (i < _player1Score)
                {
                    game.WonPoint(Player1Name);
                }
                if (i < _player2Score)
                {
                    game.WonPoint(Player2Name);
                }
            }
            Assert.AreEqual(_expectedScore, game.GetScore());
        }
Esempio n. 9
0
        protected void CheckAllScores(ITennisGame game, int player1Score, int player2Score, string expectedScore)
        {
            var highestScore = Math.Max(player1Score, player2Score);

            for (var i = 0; i < highestScore; i++)
            {
                if (i < player1Score)
                {
                    game.WonPoint("player1");
                }
                if (i < player2Score)
                {
                    game.WonPoint("player2");
                }
            }
            Assert.AreEqual(expectedScore, game.GetScore());
        }
Esempio n. 10
0
        public void checkAllScores(ITennisGame game)
        {
            int highestScore = Math.Max(this.player1Score, this.player2Score);

            for (int i = 0; i < highestScore; i++)
            {
                if (i < this.player1Score)
                {
                    game.WonPoint("player1");
                }
                if (i < this.player2Score)
                {
                    game.WonPoint("player2");
                }
            }
            Assert.AreEqual(this.expectedScore, game.GetScore());
        }
Esempio n. 11
0
        //[Test]
        //public void checkTennisGame2()
        //{
        //    TennisGame2 game = new TennisGame2("player1", "player2");
        //    checkAllScores(game);
        //}

        //[Test]
        //public void checkTennisGame3()
        //{
        //    TennisGame3 game = new TennisGame3("player1", "player2");
        //    checkAllScores(game);
        //}

        public void CheckAllScores(ITennisGame game)
        {
            int highestScore = Math.Max(m_Player1Score, m_Player2Score);

            for (int i = 0; i < highestScore; i++)
            {
                if (i < m_Player1Score)
                {
                    game.WonPoint(Names.Player1);
                }
                if (i < m_Player2Score)
                {
                    game.WonPoint(Names.Player2);
                }
            }
            Assert.AreEqual(m_ExpectedScore, game.GetScore());
        }
Esempio n. 12
0
        private void CheckAllScores(ITennisGame game)
        {
            var highestScore = Math.Max(this.player1Score, this.player2Score);

            for (var i = 0; i < highestScore; i++)
            {
                if (i < this.player1Score)
                {
                    game.WonPoint(this.Player1);
                }
                if (i < this.player2Score)
                {
                    game.WonPoint(this.Player2);
                }
            }
            Assert.AreEqual(this.expectedScore, game.GetScore());
        }
Esempio n. 13
0
        private void CheckScore(ITennisGame game, PlayerScore score)
        {
            var highestScore = Math.Max(score.Player1Score, score.Player2Score);

            for (var i = 0; i < highestScore; i++)
            {
                if (i < score.Player1Score)
                {
                    game.WonPoint("player1");
                }
                if (i < score.Player2Score)
                {
                    game.WonPoint("player2");
                }
            }
            Assert.Equal(score.ExpectedScore, game.GetScore());
        }
        private static void RealisticTennisGame(ITennisGame game)
        {
            var pointsWon = new List <Point>
            {
                new Point(player1Name, "Fifteen-Love"),
                new Point(player1Name, "Thirty-Love"),
                new Point(player2Name, "Thirty-Fifteen"),
                new Point(player2Name, "Thirty-All"),
                new Point(player1Name, "Forty-Thirty"),
                new Point(player1Name, "Love-All"),
            };

            foreach (var pointWon in pointsWon)
            {
                game.WonPoint(pointWon.playerName);
                Assert.AreEqual(pointWon.score, game.GetScore());
            }
        }
Esempio n. 15
0
        private void RealisticTennisGame(ITennisGame game)
        {
            string[] points         = { "player1", "player1", "player2", "player2", "player1", "player1" };
            string[] expectedScores = { "Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1" };
            for (var i = 0; i < 6; i++)
            {
                if (points[i].Equals("player1"))
                {
                    game.Player1WonPoint();
                }
                else
                {
                    game.Player2WonPoint();
                }

                Assert.AreEqual(expectedScores[i], game.GetScore());
            }
        }
Esempio n. 16
0
 public void ConvertScoresToResults(ITennisGame game, int player1Score, int player2Score, string expectedScore)
 {
     CheckAllScores(game, player1Score, player2Score, expectedScore);
 }
Esempio n. 17
0
        public void CheckAllScores(int player1Score, int player2Score, string expectedScore, ITennisGame game)
        {
            int highestScore = Math.Max(player1Score, player2Score);

            for (int i = 0; i < highestScore; i++)
            {
                if (i < player1Score)
                {
                    game.WonPoint("player1");
                }
                if (i < player2Score)
                {
                    game.WonPoint("player2");
                }
            }

            Assert.Equal(expectedScore, game.GetScore());
        }
 public void checkAllScores(ITennisGame game)
 {
     int highestScore = Math.Max(this.player1Score, this.player2Score);
     for (int i = 0; i < highestScore; i++)
     {
         if (i < this.player1Score)
             game.WonPoint("player1");
         if (i < this.player2Score)
             game.WonPoint("player2");
     }
     Assert.AreEqual(this.expectedScore, game.GetScore());
 }