コード例 #1
0
ファイル: FloorPlanTest.cs プロジェクト: ejbelt/RogueElements
        public void TransferBorderToAdjacents(int index, bool isHall, int expectedRoom, int expectedHall)
        {
            List <Mock <IRoomGen> >           roomGenTarget = new List <Mock <IRoomGen> >();
            List <Mock <IPermissiveRoomGen> > hallGenTarget = new List <Mock <IPermissiveRoomGen> >();

            var floorPlan = new TestFloorPlan();

            floorPlan.InitSize(new Loc(22, 14));

            for (int ii = 0; ii < 5; ii++)
            {
                Mock <IRoomGen> roomGen = new Mock <IRoomGen>(MockBehavior.Strict);
                roomGen.SetupGet(p => p.Draw).Returns(Rect.Empty);
                if (ii == 1 || ii == 3)
                {
                    roomGen.Setup(p => p.ReceiveOpenedBorder(It.IsAny <IRoomGen>(), It.IsAny <Dir4>()));
                    roomGenTarget.Add(roomGen);
                }

                var roomPlan = new FloorRoomPlan(roomGen.Object);
                roomPlan.Adjacents.Add(new RoomHallIndex(1, false));
                roomPlan.Adjacents.Add(new RoomHallIndex(3, false));
                roomPlan.Adjacents.Add(new RoomHallIndex(1, true));
                roomPlan.Adjacents.Add(new RoomHallIndex(3, true));
                floorPlan.PublicRooms.Add(roomPlan);
            }

            for (int ii = 0; ii < 5; ii++)
            {
                Mock <IPermissiveRoomGen> roomGen = new Mock <IPermissiveRoomGen>(MockBehavior.Strict);
                roomGen.SetupGet(p => p.Draw).Returns(Rect.Empty);
                if (ii == 1 || ii == 3)
                {
                    roomGen.Setup(p => p.ReceiveOpenedBorder(It.IsAny <IRoomGen>(), It.IsAny <Dir4>()));
                    hallGenTarget.Add(roomGen);
                }

                var roomPlan = new FloorHallPlan(roomGen.Object);
                roomPlan.Adjacents.Add(new RoomHallIndex(1, false));
                roomPlan.Adjacents.Add(new RoomHallIndex(3, false));
                roomPlan.Adjacents.Add(new RoomHallIndex(1, true));
                roomPlan.Adjacents.Add(new RoomHallIndex(3, true));
                floorPlan.PublicHalls.Add(roomPlan);
            }

            IRoomGen from = floorPlan.GetRoomHall(new RoomHallIndex(index, isHall)).RoomGen;

            floorPlan.TransferBorderToAdjacents(new RoomHallIndex(index, isHall));

            for (int ii = 0; ii < roomGenTarget.Count; ii++)
            {
                if (ii >= roomGenTarget.Count - expectedRoom)
                {
                    roomGenTarget[ii].Verify(p => p.ReceiveOpenedBorder(from, It.IsAny <Dir4>()), Times.Exactly(1));
                }
                else
                {
                    roomGenTarget[ii].Verify(p => p.ReceiveOpenedBorder(from, It.IsAny <Dir4>()), Times.Exactly(0));
                }
            }

            for (int ii = 0; ii < hallGenTarget.Count; ii++)
            {
                if (ii >= hallGenTarget.Count - expectedHall)
                {
                    hallGenTarget[ii].Verify(p => p.ReceiveOpenedBorder(from, It.IsAny <Dir4>()), Times.Exactly(1));
                }
                else
                {
                    hallGenTarget[ii].Verify(p => p.ReceiveOpenedBorder(from, It.IsAny <Dir4>()), Times.Exactly(0));
                }
            }
        }