示例#1
0
 public void Test1515()
 {
     Game game = new Game();
     game.PlayerOneWinsPoint();
     game.PlayerTwoWinsPoint();
     Assert.AreEqual("15 all", game.Score());
 }
示例#2
0
 public Controller()
 {
     Game = new Game();
     Player1Name = "Bart";
     Player2Name = "Stefan";
     CreateScoreBoard();
 }
示例#3
0
 public void Intermezzo_ScoringWhenAWinnerThrows2()
 {
     var game = new Game();
     game.Player1Scores();
     game.Player1Scores();
     game.Player1Scores();
     game.Player1Scores();
     Assert.Throws<InvalidOperationException>(game.Player2Scores);
 }
示例#4
0
 private void InitializeCurrentGame()
 {
     if (playerTwoGames == playerOneGames && playerOneGames == 6)
         currentGame = new Tiebreak();
     else
         currentGame = new Game();
     currentGame.PlayerOneWins += PlayerOneWinsGame;
     currentGame.PlayerTwoWins += PlayerTwoWinsGame;
 }
示例#5
0
        public void TestDeuce()
        {
            Game game = new Game();
            for (int i = 0; i < 5; i++)
            {
                game.PlayerOneWinsPoint();
                game.PlayerTwoWinsPoint();
            }

            Assert.AreEqual("deuce", game.Score());
        }
示例#6
0
        public void Test3030()
        {
            Game game = new Game();
            for (int i = 0; i < 2; i++)
            {
                game.PlayerOneWinsPoint();
                game.PlayerTwoWinsPoint();
            }

            Assert.AreEqual("30 all", game.Score());
        }
示例#7
0
        public void TestAdvP2()
        {
            Game game = new Game();
            for (int i = 0; i < 3; i++)
            {
                game.PlayerOneWinsPoint();
                game.PlayerTwoWinsPoint();
            }
            game.PlayerTwoWinsPoint();

            Assert.AreEqual("advantage player two", game.Score());
        }
示例#8
0
 public void Deuce_ScoreDeuce()
 {
     const string expected = "deuce";
     var game = new Game();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     var actual = game.ScoreString;
     Assert.AreEqual(expected, actual);
 }
示例#9
0
 public void AdvantagePlayer1_ScoreAD_40()
 {
     const string expected = "AD-40";
     var game = new Game();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     var actual = game.ScoreString;
     Assert.AreEqual(expected, actual);
 }
示例#10
0
 public void SecondAdvantagePlayer2_Score40_AD()
 {
     const string expected = "40-AD";
     var game = new Game();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     var actual = game.ScoreString;
     Assert.AreEqual(expected, actual);
 }
示例#11
0
 public void Player2LoveGame_Player2Wins()
 {
     const int expected = 2;
     var game = new Game();
     game.Player2Scores();
     game.Player2Scores();
     game.Player2Scores();
     game.Player2Scores();
     var actual = game.Winner;
     Assert.AreEqual(expected, actual);
 }
示例#12
0
 public void Player2LoveGame_AWinner()
 {
     const bool expected = true;
     var game = new Game();
     game.Player2Scores();
     game.Player2Scores();
     game.Player2Scores();
     game.Player2Scores();
     var actual = game.HasWinner;
     Assert.AreEqual(expected, actual);
 }
示例#13
0
 public void Player1Scores_Score15_0()
 {
     var game = new Game();
     const string expected = "15-0";
     game.Player1Scores();
     var actual = game.ScoreString;
     Assert.AreEqual(expected, actual);
 }
示例#14
0
 public void TestTripleGamePoint()
 {
     Game game = new Game();
     for (int i = 0; i < 3; i++)
     {
         game.PlayerOneWinsPoint();
     }
     Assert.AreEqual("40 - love", game.Score());
 }
示例#15
0
 public void Intermezzo_ThrowWhenRequestingWinnerIfNoWinner()
 {
     var game = new Game();
     Assert.Throws<InvalidOperationException>(() => { var irrelevant = game.Winner; });
 }
示例#16
0
 public void TestLoveAll()
 {
     Game game = new Game();
     Assert.AreEqual("love all", game.Score());
 }
示例#17
0
 public void TestGameOver()
 {
     Game game = new Game();
     game.PlayerTwoWinsPoint();
     game.PlayerOneWinsPoint();
     game.PlayerTwoWinsPoint();
     game.PlayerTwoWinsPoint();
     game.PlayerTwoWinsPoint();
     Assert.AreEqual(true, game.GameOver);
 }
示例#18
0
 public void NewGame_Score0_0()
 {
     const string expected = "0-0";
     var actual = new Game().ScoreString;
     Assert.AreEqual(expected, actual);
 }
示例#19
0
 public void SetUp()
 {
     m_Game = new Game();
     m_Player1Name = "Timo";
     m_Player2Name = "Stefan";
 }
示例#20
0
        public void TestP2Wins()
        {
            Game game = new Game();
            for (int i = 0; i < 3; i++)
            {
                game.PlayerOneWinsPoint();
                game.PlayerTwoWinsPoint();
            }
            game.PlayerTwoWinsPoint();
            game.PlayerTwoWinsPoint();

            Assert.AreEqual("player two wins", game.Score());
        }
示例#21
0
 public void NewGame_NoWinner()
 {
     const bool expected = false;
     var actual = new Game().HasWinner;
     Assert.AreEqual(expected, actual);
 }
示例#22
0
 public ScoreBoard(Game game, string player1Name, string player2Name)
 {
     m_Game = game;
     m_PlayerNames = new[] {player1Name, player2Name};
 }
示例#23
0
 public void Player1Advantage_NoWinner()
 {
     const bool expected = false;
     var game = new Game();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     game.Player2Scores();
     game.Player1Scores();
     var actual = game.HasWinner;
     Assert.AreEqual(expected, actual);
 }
示例#24
0
 public void Player1ScoresThrice_Player2ScoresOnce_Score40_15()
 {
     var game = new Game();
     const string expected = "40-15";
     game.Player1Scores();
     game.Player1Scores();
     game.Player1Scores();
     game.Player2Scores();
     var actual = game.ScoreString;
     Assert.AreEqual(expected, actual);
 }