Пример #1
0
        public void AddPlayersTest()
        {
            Board board = new Board();
            IPlayer player1 = new SimplePlayer();
            IPlayer player2 = new SimplePlayer();
            board.AddPlayer(player1);
            board.AddPlayer(player2);

            Assert.IsNotNull(board.Players);
            Assert.AreEqual(2, board.Players.Count);

            Assert.AreEqual(player1, board.CurrentPlayer);
            board.NextPlayer();
            Assert.AreEqual(player2, board.CurrentPlayer);
            board.NextPlayer();
            Assert.AreEqual(player1, board.CurrentPlayer);
        }
Пример #2
0
 private static Board Default2PlayerSetup()
 {
     Board board = new Board();
     IPlayer player1 = new SimplePlayer();
     IPlayer player2 = new SimplePlayer();
     board.AddPlayer(player1);
     board.AddPlayer(player2);
     return board;
 }
Пример #3
0
        public void SetInvalidPlayerTest()
        {
            Board board = DiscardOnly2PlayerSetup();

            IPlayer unknownPlayer = new SimplePlayer();
            board.SetCurrentPlayer(unknownPlayer);
        }
Пример #4
0
        public void PlayManyGamesTest()
        {
            IPlayer player1 = new SimplePlayer();
            IPlayer player2 = new DiscardOnlyPlayer();
            int NumDrawGames = 0;
            const int TotalGamesPlayed = 25;

            for (int gameNumber = 0; gameNumber < TotalGamesPlayed; gameNumber++)
            {
                Board board = new Board();
                board.AddPlayer(player1);
                board.AddPlayer(player2);

                board.PrepGame();
                board.PlayGame();

                if (board.Winner == null)
                    NumDrawGames++;
            }

            Debug.WriteLine(string.Format("{0} won {1}, {2} won {3}. {4} Drawn = Total {5}", player1, player1.GamesWon, player2, player2.GamesWon, NumDrawGames, TotalGamesPlayed));
            Assert.AreEqual(TotalGamesPlayed, NumDrawGames+player1.GamesWon + player2.GamesWon, "Total number of games won and drawn must match games played.");
        }
Пример #5
0
        public void ToStringTest()
        {
            IPlayer target = new SimplePlayer();

            Assert.IsTrue(target.ToString().StartsWith("SimplePlayer "), "SkipBo.SimplePlayer.GetName was not set correctly.");
        }
Пример #6
0
 public void PlayerConstructorTest()
 {
     IPlayer player1 = new SimplePlayer();
     Assert.IsTrue(player1.GetName.StartsWith("SimplePlayer "));
 }
Пример #7
0
        public void GetNameTest()
        {
            IPlayer target = new SimplePlayer("Freddy");

            Assert.AreEqual("Freddy", target.GetName, "SkipBo.SimplePlayer.GetName was not set correctly.");
        }