private static void TestFourTanksTryingToMoveIntoAWall() { TestHelper.DisplayTestTitle("Test 4 tanks each trying to move into a wall"); bool[,] isAWall = new bool[20, 20]; Rectangle walls = new Rectangle(8, 8, 12, 12); BoardHelper.AddWallsToBoard(ref isAWall, walls); Unit[] tanks = new Unit[Constants.TANK_COUNT]; Unit topUnit = new Unit { X = 10, Y = 5, Direction = Direction.DOWN, Action = Core.Action.DOWN }; Unit rightUnit = new Unit { X = 15, Y = 10, Direction = Direction.LEFT, Action = Core.Action.LEFT }; Unit bottomUnit = new Unit { X = 10, Y = 15, Direction = Direction.UP, Action = Core.Action.UP }; Unit leftUnit = new Unit { X = 5, Y = 10, Direction = Direction.RIGHT, Action = Core.Action.RIGHT }; tanks[0] = topUnit; tanks[1] = rightUnit; tanks[2] = bottomUnit; tanks[3] = leftUnit; MoveStatus[] expectedStatuses = { MoveStatus.Cancelled, MoveStatus.Cancelled, MoveStatus.Cancelled, MoveStatus.Cancelled }; TestHelper.DisplayBoardResolveAndCheckExpectations("FourTanksMovingIntoAWall", ref isAWall, expectedStatuses, tanks, imageFolderPath: ImageFolderPath); }
private static void TestTanksFollowingOneAnother(string testTitle, int indexOfBlockedTank = -1) { TestHelper.DisplayTestTitle(testTitle); bool[,] isAWall = new bool[35, 35]; MoveStatus[] expectedMoveStatuses = { MoveStatus.Approved, MoveStatus.Approved, MoveStatus.Approved, MoveStatus.Approved }; Unit[] tanks = new Unit[Constants.TANK_COUNT]; for (int i = 0; i < tanks.Length; i++) { Unit newUnit = new Unit { Action = Core.Action.DOWN, Direction = Direction.DOWN, X = 10 + 3 * i, Y = 10 + 5 * i }; tanks[i] = newUnit; // Add a wall in front of a tank (if index is within range): if (indexOfBlockedTank == i) { Rectangle wall = new Rectangle(0, newUnit.Y + 3, newUnit.X, newUnit.Y + 3); BoardHelper.AddWallsToBoard(ref isAWall, wall); // was: isAWall[newUnit.X, newUnit.Y + 3] = true; } // Set the expectation to failure for all tanks up to and including the one with the wall in front of it if (i <= indexOfBlockedTank) { expectedMoveStatuses[i] = MoveStatus.Cancelled; } } string imageFileName = indexOfBlockedTank >= 0 ? String.Format("TanksFollowingOneAnother_WallBeforeTank_{0}", indexOfBlockedTank) : "TanksFollowingOneAnother"; TestHelper.DisplayBoardResolveAndCheckExpectations(imageFileName, ref isAWall, expectedMoveStatuses, tanks, imageFolderPath: ImageFolderPath); }