public void GetDescription_ValidId_ReturnCorrectDescription() { for (int i = 0; i < mazeSize * mazeSize; i++) { maze.Rooms[i].Description = i.ToString(); } Assert.Equal("0", mi.GetDescription(0)); Assert.Equal("1", mi.GetDescription(1)); Assert.Equal("2", mi.GetDescription(2)); Assert.Equal("3", mi.GetDescription(3)); }
static void Main(string[] args) { int mazesize = 3; var mi = new MazeIntegration(); char direction; int currentIndex; int? selectedRoom; mi.BuildMaze(mazesize); currentIndex = mi.GetEntranceRoom(); while (true) { if (mi.HasTreasure(currentIndex)) { Console.WriteLine($"You found the treasure!"); break; } else if (mi.CausesInjury(currentIndex)) { Console.WriteLine(mi.GetDescription(currentIndex)); Console.WriteLine("Game over!"); break; } else { Console.WriteLine($"{mi.GetDescription(currentIndex)}"); } while (true) { Console.Write($"Enter a direction: "); direction = Console.ReadKey().KeyChar.ToString().ToUpper()[0]; Console.WriteLine(); selectedRoom = mi.GetRoom(currentIndex, direction); if (selectedRoom == null) { Console.WriteLine($"You face a wall, select a different direction."); continue; } currentIndex = (int)selectedRoom; break; } } Console.ReadKey(); }