Esempio n. 1
0
        public void Generate()
        {
            IRandom random = MockRepository.GenerateMock <IRandom>();

            random.Stub(r => r.Next(Arg <int> .Is.Anything)).Return(0);

            IMazeGenerator generator = new DepthFirstMazeGenerator(random);

            MazeGenerationOptions options = new MazeGenerationOptions
            {
                Width  = 3,
                Height = 3
            };
            Maze maze = generator.Generate(options);

            Assert.AreEqual(3, maze.Length);
            Assert.IsTrue(maze.All(m => m.Length == 3));

            Assert.IsTrue(maze[0][0].HasWall(MazeWall.Left | MazeWall.Right));
            Assert.IsTrue(maze[0][1].HasWall(MazeWall.Left | MazeWall.Right));
            Assert.IsTrue(maze[0][2].HasWall(MazeWall.Left));

            Assert.IsTrue(maze[1][2].HasWall(MazeWall.Top | MazeWall.Right));
            Assert.IsTrue(maze[1][1].HasWall(MazeWall.Right | MazeWall.Left));
            Assert.IsTrue(maze[1][0].HasWall(MazeWall.Bottom | MazeWall.Left));

            Assert.IsTrue(maze[2][0].HasWall(MazeWall.Bottom | MazeWall.Right));
            Assert.IsTrue(maze[2][1].HasWall(MazeWall.Left | MazeWall.Right));
            Assert.IsTrue(maze[2][2].HasWall(MazeWall.Top | MazeWall.Left | MazeWall.Right));
        }