private void SetUpNewTennisGame()
 {
     tennisGame = new TennisGame
     {
         Player1 = new Player(),
         Player2 = new Player()
     };
 }
示例#2
0
 public void Test_FourScoresPlayerOne_GameOver()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     Ashure.That(game.IsOver().IsTrue());
 }
示例#3
0
 public void Test_FourScoresPlayerOne_WinnerIsPlayerOne()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     Ashure.That(game.GetWinner().Equals(TennisGame.PLAYER_A));
 }
示例#4
0
        static void Main(string[] args)
        {
            TennisGame tennisGame = new TennisGame()
            {
                PlayerAScore = 5,
                PlayerBScore = 3
            };

            string result = tennisGame.GetScore();

            Console.WriteLine(result);
        }
示例#5
0
 public void Test_FourScoresPlayerTwoAndThreeScoresPlayerOne_ScoreIsAdvantagePlayerTwo()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals(TennisGame.ADVANTAGE_PLAYER_B));
 }
示例#6
0
 public void Test_FourScoresPlayerTwoAndThreeScoresPlayerOne_GameNotOver()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.IsOver().IsFalse());
 }
示例#7
0
        public void Return_6_7_when_ItsTiebreack()
        {
            tennis = new TennisGame();

            Player1WinsAGame(); //1-0

            Player1WinsAGame(); //2-0

            Player1WinsAGame(); //3-0

            Player1WinsAGame(); //4-0

            Player1WinsAGame(); //5-0


            Player2WinsAGame(); //5-1

            Player2WinsAGame(); //5-2

            Player2WinsAGame(); //5-3

            Player2WinsAGame(); //5-4

            Player2WinsAGame(); //5-5

            Player1WinsAGame(); //6-5

            Player2WinsAGame(); //6-6

            //TIEBreack
            tennis.Player1WinsTheBall(); //1-0
            tennis.Player1WinsTheBall(); //2-0
            tennis.Player1WinsTheBall(); //3-0
            tennis.Player1WinsTheBall(); //4-0
            tennis.Player1WinsTheBall(); //5-0
            tennis.Player2WinsTheBall(); //5-1
            tennis.Player2WinsTheBall(); //5-2
            tennis.Player2WinsTheBall(); //5-3
            tennis.Player2WinsTheBall(); //5-4
            tennis.Player2WinsTheBall(); //5-5
            tennis.Player2WinsTheBall(); //5-6
            tennis.Player1WinsTheBall(); //6-6
            tennis.Player2WinsTheBall(); //6-7


            Assert.AreEqual(tennis.DisplayScore(), "6 - 7");
        }
示例#8
0
 public void Test_OneScorePlayerB_CountIsZeroToFiveteen()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals("0:15"));
 }
示例#9
0
 public void SetUp()
 {
     _tennisGame = new TennisGame();
 }
示例#10
0
 public void Test_WrongPlayer_Throws()
 {
     var game = new TennisGame();
     Action<int> throwingCall = a => game.ScorePoint(a);
     Ashure.That(throwingCall.Throws<ArgumentOutOfRangeException, int>(5));
 }
示例#11
0
 public void Test_TwoScoresEach_CountIsThirtyToThirty()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals("30:30"));
 }
示例#12
0
 public void Test_TwoScorePlayerB_CountIsZeroToThirty()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals("0:30"));
 }
示例#13
0
 public void Test_TwoScorePlayerA_CountIsThirtyToZero()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     Ashure.That(game.GetScore().Equals("30:0"));
 }
示例#14
0
 public void Test_ThreeScoresEach_CountIsDeuce()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals(TennisGame.DEUCE));
 }
示例#15
0
 public void Test_OneScorePlayerA_CountIsFiveteenToZero()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     Ashure.That(game.GetScore().Equals("15:0"));
 }
示例#16
0
 public void Test_OneScoreEach_CountIsFiveteenToFiveteen()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals("15:15"));
 }
示例#17
0
 public void Test_NotFinished_NoWinner()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     game.ScorePoint(TennisGame.PLAYER_A);
     Ashure.That(game.GetWinner().HasValue.IsFalse());
 }
示例#18
0
 public void Test_NoScores_CountIsZeroToZero()
 {
     var game = new TennisGame();
     Ashure.That(game.GetScore().Equals("0:0"));
 }
示例#19
0
 public void Test_ScoringTooOften_Throws()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);   // 15:0
     game.ScorePoint(TennisGame.PLAYER_A);   // 30:0
     game.ScorePoint(TennisGame.PLAYER_A);   // 40:0
     game.ScorePoint(TennisGame.PLAYER_A);   // Win
     Action<int> throwingCall = a => game.ScorePoint(a);
     Ashure.That(throwingCall.Throws<InvalidOperationException, int>(TennisGame.PLAYER_A));
 }
示例#20
0
 public void Init()
 {
     tennis = new TennisGame();
 }