예제 #1
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));
 }
예제 #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_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));
 }
예제 #4
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());
 }
예제 #5
0
 public void Test_WrongPlayer_Throws()
 {
     var game = new TennisGame();
     Action<int> throwingCall = a => game.ScorePoint(a);
     Ashure.That(throwingCall.Throws<ArgumentOutOfRangeException, int>(5));
 }
예제 #6
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"));
 }
예제 #7
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"));
 }
예제 #8
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));
 }
예제 #9
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"));
 }
예제 #10
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));
 }
예제 #11
0
 public void Test_OneScorePlayerB_CountIsZeroToFiveteen()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_B);
     Ashure.That(game.GetScore().Equals("0:15"));
 }
예제 #12
0
 public void Test_OneScorePlayerA_CountIsFiveteenToZero()
 {
     var game = new TennisGame();
     game.ScorePoint(TennisGame.PLAYER_A);
     Ashure.That(game.GetScore().Equals("15:0"));
 }
예제 #13
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"));
 }
예제 #14
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());
 }