public void ScoresAreAddedToCorrectPlayer() { TennisGame1 game = new TennisGame1("Gino", "Simon", ScoreType.WithAd); game.WonPoint("Gino"); game.WonPoint("Simon"); Assert.AreEqual("Fifteen-All", game.GetScore()); }
public void PlayerOneWinsTwoGamesWithSecondGameGoingToAdvantage() { var game = new TennisGame1(new GameScore(player1Name, player2Name)); 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"), new Point(player1Name, "Fifteen-Love"), new Point(player2Name, "Fifteen-All"), new Point(player1Name, "Thirty-Fifteen"), new Point(player2Name, "Thirty-All"), new Point(player2Name, "Thirty-Forty"), new Point(player1Name, "Deuce"), new Point(player1Name, "Advantage player1"), new Point(player2Name, "Deuce"), new Point(player1Name, "Advantage player1"), new Point(player1Name, "Love-All"), }; foreach (var pointWon in pointsWon) { game.WonPoint(pointWon.playerName); Assert.AreEqual(pointWon.score, game.GetScore()); } Assert.AreEqual(2, game.GetGamesWon(player1Name)); Assert.AreEqual(0, game.GetGamesWon(player2Name)); }
public void NonExistingNameWonPoint() { var game = new TennisGame1("player1", "player2"); game.WonPoint("player3"); Assert.AreEqual(game.GetScore(), "Love-All"); }
public void OnlyAllowTwoPlayers() { var game = new TennisGame1(new GameScore(player1Name, player2Name)); var exception = Assert.Throws <PlayerNotFoundException>(() => game.WonPoint("player3")); Assert.AreEqual("player3 not found.", exception.Message); }
public void ActualPlayerHasWon() { var game = new TennisGame1("Vojta", "Jakub"); for (int i = 0; i < 6; ++i) { game.WonPoint("Vojta"); } Assert.AreEqual(game.GetScore(), "Win for Vojta"); }