public void winLossTest() { Node[] nodes = constructBasicBoard(); Player mrX = new MrX("Mr. X", 0); Player detective = new Detective("Detective", 1); Dictionary <int, Player> players = new Dictionary <int, Player>(); players.Add(mrX.getId(), mrX); players.Add(detective.getId(), detective); mrX.setLocation(nodes[0]); detective.setLocation(nodes[4]); int dummyWinningPlayerId; Assert.False(GameLogic.checkWin(players, out dummyWinningPlayerId)); detective.move(nodes[0], TransportType.taxi); int firstWinningPlayerId; bool gameWon = GameLogic.checkWin(players, out firstWinningPlayerId); Assert.True(gameWon); Assert.AreEqual(1, firstWinningPlayerId); for (int i = 1; i < 10; i++) { detective.move(nodes[4], TransportType.taxi); } int secondWinningPlayerId; gameWon = GameLogic.checkWin(players, out secondWinningPlayerId); Assert.True(gameWon); Assert.AreEqual(0, secondWinningPlayerId); for (int i = 0; i < 8; i++) { detective.move(nodes[3], TransportType.bus); } for (int i = 0; i < 4; i++) { detective.move(nodes[3], TransportType.underground); } int thirdWinningPlayerId; gameWon = GameLogic.checkWin(players, out thirdWinningPlayerId); Assert.True(gameWon); Assert.AreEqual(0, thirdWinningPlayerId); }
public void winLossTest() { Node[] nodes = constructBasicBoard(); Player mrX = new MrX("Mr. X", 0); Player detective = new Detective("Detective", 1); Dictionary<int, Player> players = new Dictionary<int, Player>(); players.Add(mrX.getId(), mrX); players.Add(detective.getId(), detective); mrX.setLocation(nodes[0]); detective.setLocation(nodes[4]); int dummyWinningPlayerId; Assert.False(GameLogic.checkWin(players, out dummyWinningPlayerId)); detective.move(nodes[0], TransportType.taxi); int firstWinningPlayerId; bool gameWon = GameLogic.checkWin (players, out firstWinningPlayerId); Assert.True(gameWon); Assert.AreEqual(1, firstWinningPlayerId); for(int i = 1; i < 10; i++){ detective.move(nodes[4], TransportType.taxi); } int secondWinningPlayerId; gameWon = GameLogic.checkWin (players, out secondWinningPlayerId); Assert.True(gameWon); Assert.AreEqual(0, secondWinningPlayerId); for(int i = 0; i < 8; i++){ detective.move(nodes[3], TransportType.bus); } for(int i = 0; i < 4; i++){ detective.move(nodes[3], TransportType.underground); } int thirdWinningPlayerId; gameWon = GameLogic.checkWin (players, out thirdWinningPlayerId); Assert.True(gameWon); Assert.AreEqual(0, thirdWinningPlayerId); }