示例#1
0
        /// <summary>
        /// Fill up the diary with blocks in all the dates
        /// </summary>
        /// <param name="businessId">business</param>
        /// <param name="startDate">start date</param>
        /// <param name="endDate">end date</param>
        /// <param name="cultureCode">culture for room info</param>
        public static void FillDateRangeWithBlocks(long businessId, DateTime startDate, DateTime endDate, string cultureCode)
        {
            RoomInformationManager roomManager = new RoomInformationManager();
            Model.Room.RoomInformation roomInfo = roomManager.GetRoomInformation(businessId, cultureCode);
            CloseoutManager closeoutManager = new CloseoutManager();
            while (startDate.Date < endDate.Date)
            {
                foreach (Model.Room.RoomType rt in roomInfo.RoomTypes)
                {
                    foreach (Model.Room.Room r in rt.Rooms)
                    {
                        try
                        {
                            
                            closeoutManager.CreateCloseout(new Closeout
                            {
                                BusinessId = businessId,
                                CloseoutReasonId = 1,
                                StartDate = startDate,
                                EndDate = startDate.AddDays(1),
                                RoomId = r.Id,
                                Description = "Load testing"
                            });
                            
                        }
                        catch
                        {
                            // its ok, continue on, means there already was a block there
                        }
                    }
                }

                startDate = startDate.AddDays(1);
            }
        }
            public void GetRoomInformationValidBusinessReturnsPopulatedRoomInformation()
            {
                // Arrange
                long businessId = 1;
                const string CULTURE_CODE = "en-GB";

                IRoomInformationDao stubRoomInformationDao = MockRepository.GenerateStub<IRoomInformationDao>();
                RoomInformationManager roomInformationManager = new RoomInformationManager();

                RoomInformation daoReturnData = new RoomInformation
                {
                    RoomTypes = new List<RoomType>
                    {
                        new RoomType
                        {
                            Id = 1,
                            BusinessId = 1,
                            Name = "RoomType1",
                            Rooms = new List<Room>
                            {
                                new Room
                                {
                                    Id = 1,
                                    BusinessId = 1,
                                    IsCombined = false,
                                    RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE }
                                }
                            },
                            VariantRatePlans = new List<VariantRatePlan>()
                        }
                    },
                };

                stubRoomInformationDao.Stub(r => r.GetByBusiness(businessId, CULTURE_CODE)).Return(daoReturnData);

                roomInformationManager.RoomInformationDao = stubRoomInformationDao;

                // Act
                RoomInformation receivedObj = roomInformationManager.GetRoomInformation(businessId, CULTURE_CODE);

                // Assert
                Assert.IsNotNull(receivedObj, "The room information returned can't be null");
                Assert.AreEqual(1, receivedObj.RoomTypes.Count, "The room information should return one room type");
                Assert.AreEqual(1, receivedObj.RoomTypes[0].Rooms.Count, "The room type should only return one room");
            }