Exemple #1
0
        public void TestProperties()
        {
            // constructor
            Maze maze = new Maze (10, 13, Maze.WallInit.None);

            // size
            Assert.AreEqual (maze.Count, 13*10);

            // rows and columns
            Assert.AreEqual (13, maze.Rows);
            Assert.AreEqual (10, maze.Cols);

            // wall setting and unsetting
            Assert.IsTrue (maze.IsOpen (0, 0, Maze.Direction.N));
            maze.SetWall (0, 0, Maze.Direction.N);
            Assert.IsFalse (maze.IsOpen (0, 0, Maze.Direction.N));
            maze.UnsetWall (0, 0, Maze.Direction.N);
            Assert.IsTrue (maze.IsOpen (0, 0, Maze.Direction.N));

            // wall of contiguous cells
            Assert.IsTrue (maze.IsOpen(5,5, Maze.Direction.E));
            Assert.IsTrue (maze.IsOpen(6,5, Maze.Direction.W));
            maze.SetWall (5,5, Maze.Direction.E);
            Assert.IsFalse (maze.IsOpen(5,5, Maze.Direction.E));
            Assert.IsFalse (maze.IsOpen(6,5, Maze.Direction.W));
            maze.UnsetWall (6,5, Maze.Direction.W);
            Assert.IsTrue (maze.IsOpen(5,5, Maze.Direction.E));
            Assert.IsTrue (maze.IsOpen(6,5, Maze.Direction.W));
        }
Exemple #2
0
        public void TestProperties()
        {
            // constructor
            Maze maze = new Maze(10, 13, Maze.WallInit.None);

            // size
            Assert.AreEqual(maze.Count, 13 * 10);

            // rows and columns
            Assert.AreEqual(13, maze.Rows);
            Assert.AreEqual(10, maze.Cols);

            // wall setting and unsetting
            Assert.IsTrue(maze.IsOpen(0, 0, Maze.Direction.N));
            maze.SetWall(0, 0, Maze.Direction.N);
            Assert.IsFalse(maze.IsOpen(0, 0, Maze.Direction.N));
            maze.UnsetWall(0, 0, Maze.Direction.N);
            Assert.IsTrue(maze.IsOpen(0, 0, Maze.Direction.N));

            // wall of contiguous cells
            Assert.IsTrue(maze.IsOpen(5, 5, Maze.Direction.E));
            Assert.IsTrue(maze.IsOpen(6, 5, Maze.Direction.W));
            maze.SetWall(5, 5, Maze.Direction.E);
            Assert.IsFalse(maze.IsOpen(5, 5, Maze.Direction.E));
            Assert.IsFalse(maze.IsOpen(6, 5, Maze.Direction.W));
            maze.UnsetWall(6, 5, Maze.Direction.W);
            Assert.IsTrue(maze.IsOpen(5, 5, Maze.Direction.E));
            Assert.IsTrue(maze.IsOpen(6, 5, Maze.Direction.W));
        }
Exemple #3
0
        public void TestStringBuilder()
        {
            Maze maze;

            maze = new Maze(2, 2, Maze.WallInit.None);
            Assert.AreEqual(new string[] {
                "     ",
                "     ",
                "     ",
                "     ",
                "     ",
            }, maze.StrLines(2, 2, false));

            maze = new Maze(2, 2, Maze.WallInit.Perimeter);
            Assert.AreEqual(new string[] {
                "+--+--+",
                "|     |",
                "+     +",
                "|     |",
                "+--+--+",
            }, maze.StrLines(3, 2, false));

            maze = new Maze(3, 3, Maze.WallInit.Perimeter);
            Assert.AreEqual(new string[] {
                "+--+--+--+",
                "|        |",
                "|        |",
                "+        +",
                "|        |",
                "|        |",
                "+        +",
                "|        |",
                "|        |",
                "+--+--+--+",
            }, maze.StrLines(3, 3, false));

            maze = new Maze(4, 3, Maze.WallInit.Perimeter);
            maze.UnsetWall(0, 0, Maze.Direction.N);
            maze.UnsetWall(0, 2, Maze.Direction.W);
            maze.SetWall(0, 0, Maze.Direction.S);
            maze.SetWall(1, 0, Maze.Direction.E);
            maze.SetWall(1, 1, Maze.Direction.E);
            maze.SetWall(1, 1, Maze.Direction.W);
            maze.SetWall(0, 2, Maze.Direction.N);
            maze.SetWall(2, 2, Maze.Direction.N);
            maze.SetWall(3, 2, Maze.Direction.N);
            Assert.AreEqual(new string[] {
                "+   +---+---+---+",
                "|       |       |",
                "|       |       |",
                "+---+   +       +",
                "|   |   |       |",
                "|   |   |       |",
                "+---+   +---+---+",
                "                |",
                "                |",
                "+---+---+---+---+",
            }, maze.StrLines(4, 3, false));
        }
Exemple #4
0
        public void TestStringBuilder()
        {
            Maze maze;

            maze = new Maze (2, 2, Maze.WallInit.None);
            Assert.AreEqual (new string[] {
                "     ",
                "     ",
                "     ",
                "     ",
                "     ",
            }, maze.StrLines(2, 2, false));

            maze = new Maze (2, 2, Maze.WallInit.Perimeter);
            Assert.AreEqual (new string[] {
                "+--+--+",
                "|     |",
                "+     +",
                "|     |",
                "+--+--+",
            }, maze.StrLines(3, 2, false));

            maze = new Maze (3, 3, Maze.WallInit.Perimeter);
            Assert.AreEqual (new string[] {
                "+--+--+--+",
                "|        |",
                "|        |",
                "+        +",
                "|        |",
                "|        |",
                "+        +",
                "|        |",
                "|        |",
                "+--+--+--+",
            }, maze.StrLines(3, 3, false));

            maze = new Maze (4, 3, Maze.WallInit.Perimeter);
            maze.UnsetWall (0, 0, Maze.Direction.N);
            maze.UnsetWall (0, 2, Maze.Direction.W);
            maze.SetWall (0, 0, Maze.Direction.S);
            maze.SetWall (1, 0, Maze.Direction.E);
            maze.SetWall (1, 1, Maze.Direction.E);
            maze.SetWall (1, 1, Maze.Direction.W);
            maze.SetWall (0, 2, Maze.Direction.N);
            maze.SetWall (2, 2, Maze.Direction.N);
            maze.SetWall (3, 2, Maze.Direction.N);
            Assert.AreEqual (new string[] {
                "+   +---+---+---+",
                "|       |       |",
                "|       |       |",
                "+---+   +       +",
                "|   |   |       |",
                "|   |   |       |",
                "+---+   +---+---+",
                "                |",
                "                |",
                "+---+---+---+---+",
            }, maze.StrLines(4, 3, false));
        }