public void testPlayerToString() { Player player = new ComputerPlayer("test computer", new GreedyAIStrategy()); Assert.AreEqual("test computer - Computer - Greedy", player.ToString()); player = new HumanPlayer("test human"); Assert.AreEqual("test human - Human", player.ToString()); }
public void testPlayerName() { Player player = new HumanPlayer("test name"); Assert.AreEqual("test name", player.Name); player = new ComputerPlayer("test name 2", new GreedyAIStrategy()); Assert.AreEqual("test name 2", player.Name); }
static void Main(string[] args) { Game game = new Game(); Player player1 = new ComputerPlayer("GreedyAI", new GreedyAIStrategy()); Player player2 = new HumanPlayer("Test Player", new CmdLinePlayerStrategy()); game.AddPlayer(player1); game.AddPlayer(player2); game.PlayGame(); Console.WriteLine("The Winner Is: " + game.GetWinnerName()); Console.WriteLine("With a score of: " + game.GetWinningScore().ToString()); Console.ReadKey(); }
public void testMakeUnique() { List<Player> players = new List<Player>(); Player p; p = new HumanPlayer("A"); players.Add(p); p = new HumanPlayer("A"); players.Add(p); p = new HumanPlayer("B"); players.Add(p); p = new HumanPlayer("A"); players.Add(p); PlayerList pl = new PlayerList(); pl.Players = players; pl.makeNamesUnique(); Assert.AreEqual("A", pl.Players[0].Name); Assert.AreEqual("A2", pl.Players[1].Name); Assert.AreEqual("B", pl.Players[2].Name); Assert.AreEqual("A3", pl.Players[3].Name); }
public void testRemovePlayer() { List<Player> players = new List<Player>(); Player p; p = new HumanPlayer("A"); players.Add(p); p = new HumanPlayer("B"); players.Add(p); p = new HumanPlayer("C"); players.Add(p); PlayerList pl = new PlayerList(); pl.Players = players; Assert.AreEqual(3, pl.Players.Count); Assert.AreEqual("A", pl.Players[0].Name); Assert.AreEqual("B", pl.Players[1].Name); Assert.AreEqual("C", pl.Players[2].Name); pl.removePlayer("B"); Assert.AreEqual(2, pl.Players.Count); Assert.AreEqual("A", pl.Players[0].Name); Assert.AreEqual("C", pl.Players[1].Name); }
public void CheckSerialization() { PlayerList playerList = new PlayerList(); Turn turn = new Turn(); DieSet dieSet = new DieSet(); HumanPlayer hp = new HumanPlayer("Test Player Name"); ComputerPlayer cp = new ComputerPlayer("Test Computer Player", new GreedyAIStrategy()); playerList.Players.Add(hp); playerList.Players.Add(cp); dieSet.Roll(); GameState gameState = new GameState(); gameState.Players = playerList; gameState.Turn = turn; XmlSerializer serializer = new XmlSerializer(typeof(GameState)); using (TextWriter writer = new StreamWriter(@"C:\GameStateTest.xml")) { serializer.Serialize(writer, gameState); } }
public void testHumanTurn() { Player human = new HumanPlayer("Test Human", new CmdLinePlayerStrategy()); human.TakeTurn(); }
public void testHumanPlayerConstructor() { Player human = new HumanPlayer(); Assert.IsInstanceOf(typeof(HumanPlayer), human); }
public void testHumanPlayer() { Player human = new HumanPlayer("Test Human", new CmdLinePlayerStrategy()); Assert.AreEqual("Test Human", human.Name); Assert.AreEqual("Human", human.PlayerType); }