public void RealisticTennisGame(TennisGame 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());
       }
 }
예제 #2
0
 public void RealisticTennisGame(TennisGame 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());
     }
 }
 public void checkAllScores(TennisGame 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());
 }
        public void Convert_Points_To_Score(
            int player1Points, int player2Points, string expected)
        {
            // Giwen
            var game = new TennisGame(player1Points, player2Points);

            // When
            var score = game.GetScore();

            // Then
            Assert.Equal(expected, score);
        }
        public void CheckRealisticGame()
        {
            var game = new TennisGame("player1", "player2");

            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(game.PlayerList.First(p => p.Name == points[i]).Id, game.PlayerList.First(p => p.Name != points[i]).Id);
                Assert.AreEqual(expectedScores[i], game.GetScore());
            }
        }
예제 #6
0
        public void checkAllScores(TennisGame 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());
        }
예제 #7
0
        public void AssertTennisScore(int player1Score, int player2Score, string expectedScore)
        {
            var game         = new TennisGame("player1", "player2");
            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());
        }
        public void CheckTennisGame(int player1Score, int player2Score, string expectedScore)
        {
            var game         = new TennisGame("player1", "player2");
            var p1           = game.PlayerList.First(p => p.Name == "player1");
            var p2           = game.PlayerList.First(p => p.Name == "player2");
            var highestScore = Math.Max(player1Score, player2Score);

            for (var i = 0; i < highestScore; i++)
            {
                if (i < player1Score)
                {
                    game.WonPoint(p1.Id, p2.Id);
                }
                if (i < player2Score)
                {
                    game.WonPoint(p2.Id, p1.Id);
                }
            }
            Assert.AreEqual(expectedScore, game.GetScore());
        }
예제 #9
0
 private void AssertResult(string result)
 {
     Assert.AreEqual(game.GetScore(), result);
 }
예제 #10
0
        static void Main(string[] args)
        {
            TennisGame tennisGame = new TennisGame();

            Console.WriteLine(tennisGame.GetScore("Federer", "Nadal", 2, 1));
        }