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); }
private static Board Default2PlayerSetup() { Board board = new Board(); IPlayer player1 = new SimplePlayer(); IPlayer player2 = new SimplePlayer(); board.AddPlayer(player1); board.AddPlayer(player2); return board; }
public void SetInvalidPlayerTest() { Board board = DiscardOnly2PlayerSetup(); IPlayer unknownPlayer = new SimplePlayer(); board.SetCurrentPlayer(unknownPlayer); }
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."); }
public void ToStringTest() { IPlayer target = new SimplePlayer(); Assert.IsTrue(target.ToString().StartsWith("SimplePlayer "), "SkipBo.SimplePlayer.GetName was not set correctly."); }
public void PlayerConstructorTest() { IPlayer player1 = new SimplePlayer(); Assert.IsTrue(player1.GetName.StartsWith("SimplePlayer ")); }
public void GetNameTest() { IPlayer target = new SimplePlayer("Freddy"); Assert.AreEqual("Freddy", target.GetName, "SkipBo.SimplePlayer.GetName was not set correctly."); }