public void Game_Win() { // Note: You can look at MazeState/maze.bmp to see what the maze to solve looks like. var state = System.IO.File.ReadAllText(@"MazeState/state.txt"); var mazeGameController = new MazeGameController(state); var winX = 7; var winY = 1; Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryLeft()); Assert.IsTrue(mazeGameController.TryDown()); Assert.IsTrue(mazeGameController.TryDown()); Assert.IsTrue(mazeGameController.TryDown()); Assert.IsTrue(mazeGameController.TryRight()); Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryRight()); Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryRight()); Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryRight()); Assert.IsTrue(mazeGameController.TryUp()); Assert.IsTrue(mazeGameController.TryLeft()); Assert.AreEqual(winX, mazeGameController.State.PlayerPos.Item1); Assert.AreEqual(winY, mazeGameController.State.PlayerPos.Item2); // Check we can only move back Assert.IsFalse(mazeGameController.TryUp()); Assert.IsFalse(mazeGameController.TryLeft()); Assert.IsFalse(mazeGameController.TryDown()); Assert.IsTrue(mazeGameController.TryRight()); }
public void Game_Left() { var mazeGenerator = new MazeGenerator(10, 10); mazeGenerator.Generate(); var mazeGameController = new MazeGameController(mazeGenerator.Nodes); bool moved = mazeGameController.TryLeft(); if (moved) { // At least one of the player coordinates has moved. Assert.AreEqual(4, mazeGameController.State.PlayerPos.Item1); Assert.AreEqual(5, mazeGameController.State.PlayerPos.Item2); } else { Assert.AreEqual(5, mazeGameController.State.PlayerPos.Item1); Assert.AreEqual(5, mazeGameController.State.PlayerPos.Item2); } }