Exemple #1
0
        public void Love_All()
        {
            var gameId = 1;

            GivenPlayerScore(gameId, 0, 0);
            TennisGame tennisGame = new TennisGame(repo);


            ScoreShouldBe("Love All", gameId);
        }
Exemple #2
0
        public void Deuce()
        {
            var gameId = 1;

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 3, SecondPlayerScore = 3
            });

            TennisGame tennisGame = new TennisGame(repo);

            ScoreShouldBe("Deuce", gameId);
        }
Exemple #3
0
        public void Fifteen_All()
        {
            var gameId = 1;

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 1, SecondPlayerScore = 1
            });

            TennisGame tennisGame = new TennisGame(repo);

            ScoreShouldBe("Fifteen All", gameId);
        }
Exemple #4
0
        public void Love_Fifteen()
        {
            var gameId = 1;

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 0, SecondPlayerScore = 1
            });

            TennisGame tennisGame = new TennisGame(repo);

            ScoreShouldBe("Love Fifteen", gameId);
        }
Exemple #5
0
        public void Thirty_Love()
        {
            var gameId = 1;

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 2, SecondPlayerScore = 0
            });

            TennisGame tennisGame = new TennisGame(repo);

            ScoreShouldBe("Thirty Love", gameId);
        }
Exemple #6
0
        public void Joey_Win_with_4_0()
        {
            var gameId = 1;

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 4, SecondPlayerScore = 0, FirstPlayName = "Joey", SecondPlayerName = "Tom"
            });

            TennisGame tennisGame = new TennisGame(repo);

            ScoreShouldBe("Joey Win", gameId);
        }
Exemple #7
0
        public void Tom_Win()
        {
            var gameId = 1;

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 3, SecondPlayerScore = 5, FirstPlayName = "Joey", SecondPlayerName = "Tom"
            });

            TennisGame tennisGame = new TennisGame(repo);

            ScoreShouldBe("Tom Win", gameId);
        }
Exemple #8
0
        public void TestBase(Game game, string check)
        {
            IRepository <Game> repo = Substitute.For <IRepository <Game> >();

            repo.GetGame(game.Id).Returns(game);

            TennisGame tennisGame = new TennisGame(repo);

            var scoreResult = tennisGame.ScoreResult(game.Id);

            Assert.AreEqual(check, scoreResult);
        }
Exemple #9
0
        public void Love_All()
        {
            var gameId = 91;

            IRepository <Game> repo = Substitute.For <IRepository <Game> >();

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 0, SecondPlayerScore = 0
            });

            TennisGame tennisGame = new TennisGame(repo);

            var scoreResult = tennisGame.ScoreResult(gameId);

            Assert.AreEqual("Love All", scoreResult);
        }
Exemple #10
0
        public void Adv()
        {
            var gameId = 1;

            IRepository <Game> repo = Substitute.For <IRepository <Game> >();

            repo.GetGame(gameId).Returns(new Game {
                Id = gameId, FirstPlayerScore = 4, SecondPlayerScore = 3, FirstPlayerName = "Joey", SecondPlayerName = "Tom"
            });

            TennisGame tennisGame = new TennisGame(repo);

            var scoreResult = tennisGame.ScoreResult(gameId);

            Assert.AreEqual("Joey Adv", scoreResult);
        }
Exemple #11
0
        public void TennisScore_Test_第一人分數_第二人分數_預期結果(int firstPlayerScore, int secondPlayerScore, string result)
        {
            var firstPlayer   = "Joey";
            var sencondPlayer = "Tom";
            var gameId        = 1;

            IRepository <Game> repo = Substitute.For <IRepository <Game> >();

            repo.GetGame(gameId).Returns(new Game
            {
                Id = gameId,
                FirstPlayerScore  = firstPlayerScore,
                SecondPlayerScore = secondPlayerScore,
                FirstPlayerName   = firstPlayer,
                SecondPlayerName  = sencondPlayer
            });

            TennisGame tennisGame = new TennisGame(repo);

            var scoreResult = tennisGame.ScoreResult(gameId);

            Assert.AreEqual(result?.ToLower(), scoreResult?.ToLower());
        }
Exemple #12
0
 public void TestInit()
 {
     _tennisGame = new TennisGame(_repository);
 }
Exemple #13
0
 public void start()
 {
     tennisGame = new TennisGame(repo);
 }
Exemple #14
0
        private void ScoreShouldBe(string expected, int id)
        {
            TennisGame tennisGame = new TennisGame(repo);

            Assert.AreEqual(expected, tennisGame.ScoreResult(id));
        }