Exemplo n.º 1
0
        public void CreateError()
        {
            string[] inGrid =
            {
                "0",
                ".",
                "0",
            };

            Mock <IRandom> testRand = new Mock <IRandom>(MockBehavior.Strict);

            var pathGen = new GridPathTwoSides <IGridPathTestContext> {
                GapAxis = Axis4.Horiz
            };

            Mock <IRandPicker <PermissiveRoomGen <IGridPathTestContext> > > mockHalls = new Mock <IRandPicker <PermissiveRoomGen <IGridPathTestContext> > >(MockBehavior.Strict);

            pathGen.GenericHalls = mockHalls.Object;
            Mock <IRandPicker <RoomGen <IGridPathTestContext> > > mockRooms = new Mock <IRandPicker <RoomGen <IGridPathTestContext> > >(MockBehavior.Strict);

            pathGen.GenericRooms = mockRooms.Object;

            TestGridFloorPlan floorPlan = TestGridFloorPlan.InitGridToContext(inGrid);

            Assert.Throws <InvalidOperationException>(() => { pathGen.ApplyToPath(testRand.Object, floorPlan); });
        }
Exemplo n.º 2
0
        public void CreatePathMinSize()
        {
            string[] inGrid =
            {
                "0.0",
            };

            string[] outGrid =
            {
                "A#B",
            };

            Mock <IRandom> testRand = new Mock <IRandom>(MockBehavior.Strict);

            var pathGen = new GridPathTwoSides <IGridPathTestContext> {
                GapAxis = Axis4.Horiz
            };

            Mock <IRandPicker <PermissiveRoomGen <IGridPathTestContext> > > mockHalls = new Mock <IRandPicker <PermissiveRoomGen <IGridPathTestContext> > >(MockBehavior.Strict);

            mockHalls.Setup(p => p.Pick(testRand.Object)).Returns(new TestGridRoomGen());
            pathGen.GenericHalls = mockHalls.Object;
            Mock <IRandPicker <RoomGen <IGridPathTestContext> > > mockRooms = new Mock <IRandPicker <RoomGen <IGridPathTestContext> > >(MockBehavior.Strict);

            Moq.Language.ISetupSequentialResult <RoomGen <IGridPathTestContext> > roomSeq = mockRooms.SetupSequence(p => p.Pick(testRand.Object));
            roomSeq = roomSeq.Returns(new TestGridRoomGen('A'));
            roomSeq = roomSeq.Returns(new TestGridRoomGen('B'));
            pathGen.GenericRooms = mockRooms.Object;

            TestGridFloorPlan floorPlan        = TestGridFloorPlan.InitGridToContext(inGrid);
            TestGridFloorPlan compareFloorPlan = TestGridFloorPlan.InitGridToContext(outGrid);

            pathGen.ApplyToPath(testRand.Object, floorPlan);

            TestGridFloorPlan.CompareFloorPlans(floorPlan, compareFloorPlan);

            mockHalls.Verify(p => p.Pick(testRand.Object), Times.Exactly(1));
            mockRooms.Verify(p => p.Pick(testRand.Object), Times.Exactly(2));
        }