public void CheckTennisGame(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.PointScored(game.PlayerOne); } if (i < player2Score) { game.PointScored(game.PlayerTwo); } } Assert.AreEqual(expectedScore, game.GetGameScore()); }
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.PointScored(points[i] == "player1" ? game.PlayerOne : game.PlayerTwo); Assert.AreEqual(expectedScores[i], game.GetGameScore()); } }