Esempio n. 1
0
        public void AddRoomToExisting()
        {
            // add with adjacents
            TestFloorPlan floorPlan = TestFloorPlan.InitFloorToContext(
                new Loc(22, 14),
                new Rect[] { new Rect(1, 1, 2, 3) },
                new Rect[] { new Rect(6, 1, 3, 3) },
                Array.Empty <Tuple <char, char> >());

            TestFloorPlan compareFloorPlan = TestFloorPlan.InitFloorToContext(
                new Loc(22, 14),
                new Rect[] { new Rect(1, 1, 2, 3), new Rect(3, 2, 3, 5) },
                new Rect[] { new Rect(6, 1, 3, 3) },
                new Tuple <char, char>[] { Tuple.Create('A', 'B'), Tuple.Create('a', 'B') });

            var gen = new Mock <TestFloorPlanGen>(MockBehavior.Loose)
            {
                CallBase = true
            };

            gen.SetupGet(p => p.Draw).Returns(new Rect(3, 2, 3, 5));
            gen.Object.Identifier = 'B';

            floorPlan.AddRoom(gen.Object, false, new RoomHallIndex(0, false), new RoomHallIndex(0, true));

            TestFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);
        }
Esempio n. 2
0
        public void AddRoomCollideExisting(bool hall)
        {
            // add on top of existing room?
            List <Rect> rooms = new List <Rect>();
            List <Rect> halls = new List <Rect>();

            if (!hall)
            {
                rooms.Add(new Rect(1, 1, 2, 3));
            }
            else
            {
                halls.Add(new Rect(1, 1, 2, 3));
            }
            TestFloorPlan floorPlan = TestFloorPlan.InitFloorToContext(
                new Loc(22, 14),
                rooms.ToArray(),
                halls.ToArray(),
                Array.Empty <Tuple <char, char> >());

            var gen = new Mock <TestFloorPlanGen>(MockBehavior.Loose)
            {
                CallBase = true
            };

            gen.SetupGet(p => p.Draw).Returns(new Rect(2, 2, 4, 4));
            gen.Object.Identifier = 'B';

            // check the rooms
            Assert.Throws <InvalidOperationException>(() => { floorPlan.AddRoom(gen.Object, false); });
        }
Esempio n. 3
0
        public void AddRoomToEmptySpace()
        {
            // add to empty space
            TestFloorPlan floorPlan = TestFloorPlan.InitFloorToContext(
                new Loc(22, 14),
                Array.Empty <Rect>(),
                Array.Empty <Rect>(),
                Array.Empty <Tuple <char, char> >());

            TestFloorPlan compareFloorPlan = TestFloorPlan.InitFloorToContext(
                new Loc(22, 14),
                new Rect[] { new Rect(1, 1, 2, 3) },
                Array.Empty <Rect>(),
                Array.Empty <Tuple <char, char> >());

            var gen = new Mock <TestFloorPlanGen>(MockBehavior.Loose)
            {
                CallBase = true
            };

            gen.SetupGet(p => p.Draw).Returns(new Rect(1, 1, 2, 3));
            gen.Object.Identifier = 'A';
            floorPlan.AddRoom(gen.Object, false);

            TestFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);
        }
Esempio n. 4
0
        public void AddRoomToOutOfBounds(int x, int y)
        {
            // attempt to touch out of bounds
            var floorPlan = new TestFloorPlan();

            floorPlan.InitSize(new Loc(22, 14));
            Mock <TestFloorPlanGen> gen = new Mock <TestFloorPlanGen>(MockBehavior.Loose);

            gen.SetupGet(p => p.Draw).Returns(new Rect(x, y, 2, 3));
            gen.Object.Identifier = 'A';

            // check the rooms
            Assert.Throws <InvalidOperationException>(() => { floorPlan.AddRoom(gen.Object, false); });
        }