Esempio n. 1
0
    public void TestConnectRoomsRedundant()
    {
        LevelLayout layout = new LevelLayout();
        Vector2Int  loc1   = Vector2Int.zero;
        Vector2Int  loc2   = Vector2Int.right;

        bool[] expected1 = new bool[4];
        expected1[(int)Direction.Right] = true;

        bool[] expected2 = new bool[4];
        expected2[(int)Direction.Left] = true;

        layout.AddRoom(loc1);
        layout.AddRoom(loc2);
        layout.ConnectRooms(loc1, loc2);
        layout.ConnectRooms(loc1, loc2);

        Assert.IsTrue(expected1.SequenceEqual(layout.GetRoom(loc1).Openings));
        Assert.IsTrue(expected2.SequenceEqual(layout.GetRoom(loc2).Openings));
    }
Esempio n. 2
0
    public void TestConnectRoomsMissingBoth()
    {
        LevelLayout layout = new LevelLayout();
        Vector2Int  loc1   = Vector2Int.zero;
        Vector2Int  loc2   = Vector2Int.right;

        try {
            layout.ConnectRooms(loc1, loc2);
            Assert.Fail("Both null rooms should have thrown an exception");
        }
        catch (ArgumentOutOfRangeException) {
        }
    }
Esempio n. 3
0
    public void TestConnectRoomsSeparate()
    {
        LevelLayout layout = new LevelLayout();
        Vector2Int  loc1   = Vector2Int.zero;
        Vector2Int  loc2   = Vector2Int.one;

        layout.AddRoom(loc1);
        layout.AddRoom(loc2);

        try {
            layout.ConnectRooms(loc1, loc2);
            Assert.Fail("Connecting separate rooms should have thrown an exception");
        }
        catch (ArgumentOutOfRangeException) {
        }
    }
Esempio n. 4
0
    public void TestConnectRoomsValid(
        int x1, int y1,
        int x2, int y2,
        Direction dirFrom1,
        Direction dirFrom2
        )
    {
        LevelLayout layout = new LevelLayout();
        Vector2Int  loc1   = new Vector2Int(x1, y1);      //Vector2Int.zero;
        Vector2Int  loc2   = new Vector2Int(x2, y2);      //Vector2Int.right;

        bool[] expected1 = new bool[(int)Direction.Count];
        expected1[(int)dirFrom1] = true;

        bool[] expected2 = new bool[(int)Direction.Count];
        expected2[(int)dirFrom2] = true;

        layout.AddRoom(loc1);
        layout.AddRoom(loc2);
        layout.ConnectRooms(loc1, loc2);

        Assert.IsTrue(expected1.SequenceEqual(layout.GetRoom(loc1).Openings));
        Assert.IsTrue(expected2.SequenceEqual(layout.GetRoom(loc2).Openings));
    }