コード例 #1
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
 public void GetNeighbours_returns_2_Cells_for_corner_Cell()
 {
     var maze = new Maze(5, 5);
     var cornerCell = maze.Cells[0, 0];
     var neighbours = maze.TestGetNeighbours(cornerCell);
     Assert.AreEqual(2, neighbours.Count);
 }
コード例 #2
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
        public void Generate_chooses_random_starting_Cell()
        {
            var maze = new Maze(5, 5);
            maze.Generate(1);
            var startingCell1 = maze.Start;
            maze.Generate(2);
            var startingCell2 = maze.Start;

            Assert.AreNotEqual(startingCell1.X, startingCell2.X);
            Assert.AreNotEqual(startingCell1.Y, startingCell2.Y);
        }
コード例 #3
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
        public void KnockWall_removes_east_wall_if_neighbour_is_east()
        {
            var current = new Cell(0, 0);
            var neighbour = new Cell(1, 0);
            var maze = new Maze(5, 5);
            maze.TestKnockWall(current, neighbour);

            Assert.IsFalse(current.AreAllWallsIntact, "Current has still all walls intact.");
            Assert.IsFalse(neighbour.AreAllWallsIntact, "Neighbour has still all walls intact.");
            Assert.IsFalse(current.HasEastWall, "Current still has east wall.");
            Assert.IsFalse(neighbour.HasWestWall, "Neighbour still has west wall.");
        }
コード例 #4
0
        public ContentResult Generate(int width, int height, string perfect)
        {
            var maze = new Maze(width, height);
            maze.Generate(DateTime.Now.Millisecond, perfect == "on" | string.IsNullOrEmpty(perfect));

            SaveMaze(maze);

            var json = JsonConvert.SerializeObject(maze);
            SaveMazeJson(json);

            playerSavingService.ResetCurrentSavedPlayerState();

            return Content(json, "application/json");
        }
コード例 #5
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
        public void Generate_creates_Maze_with_no_cells_having_all_walls_intakt()
        {
            var maze = new Maze(5, 5);
            var foundCellWithAllWallsIntakt = false;
            maze.Generate(1);

            for (var x = 0; x < 5; x++)
            {
                if (foundCellWithAllWallsIntakt)
                {
                    break;
                }
                for (var y = 0; y < 5; y++)
                {
                    if (!maze.Cells[x, y].AreAllWallsIntact) continue;
                    foundCellWithAllWallsIntakt = true;
                    break;
                }
            }
            Assert.IsFalse(foundCellWithAllWallsIntakt);
        }
コード例 #6
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
        public void KnockWall_removes_north_wall_if_neighbour_is_north()
        {
            var current = new Cell(0, 1);
            var neighbour = new Cell(0, 0);
            var maze = new Maze(5, 5);
            maze.TestKnockWall(current, neighbour);

            Assert.IsFalse(current.AreAllWallsIntact, "Current has still all walls intact.");
            Assert.IsFalse(neighbour.AreAllWallsIntact, "Neighbour has still all walls intact.");
            Assert.IsFalse(current.HasNorthWall, "Current still has north wall.");
            Assert.IsFalse(neighbour.HasSouthWall, "Neighbour still has south wall.");
        }
コード例 #7
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
 public void Generate_creates_solvable_maze()
 {
     var maze = new Maze(5, 5);
     maze.Generate(1);
     Assert.IsTrue(maze.IsSolvable);
 }
コード例 #8
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
 public void Can_create_Maze_with_set_width_and_height()
 {
     var maze = new Maze(1,1);
     Assert.AreEqual(1, maze.Cells.GetLength(0));
     Assert.AreEqual(1, maze.Cells.GetLength(1));
 }
コード例 #9
0
ファイル: MazeTests.cs プロジェクト: LeedsSharp/MazeSharp
 public void New_Maze_is_not_solvable()
 {
     var maze = new Maze(5, 5);
     Assert.IsFalse(maze.IsSolvable);
 }