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");
            }
示例#2
0
        /// <summary>
        /// Helpful for testing bunches of bookings, creates a booking for every room / day in the given range
        /// </summary>
        /// <param name="businessId">Business to test</param>
        /// <param name="startDate">start date</param>
        /// <param name="endDate">end date</param>
        /// <param name="cultureCode">for ease of creating guests</param>
        public static void FillDateRangeWithBookings(long businessId, DateTime startDate, DateTime endDate, string cultureCode)
        {
            RoomInformationManager roomManager = new RoomInformationManager();
            Model.Room.RoomInformation roomInfo = roomManager.GetRoomInformationWithRateCache(businessId, startDate, endDate, cultureCode);
            OrderManager orderManager = new OrderManager();

            while (startDate.Date < endDate.Date)
            {
                foreach (Model.Room.RoomType rt in roomInfo.RoomTypes)
                {
                    var ratePlanToUse = rt.BaseRatePlan;
                    foreach (Model.Room.Room r in rt.Rooms)
                    {
                        Booking booking = new Booking
                        {
                            StartDate = startDate,
                            EndDate = startDate.AddDays(1),
                            BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                            RateType = new EnumEntity { Code = RateType.MANUAL },
                            BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                            Cost = 5,
                            Guest = new Guest
                            {
                                Surname = "randomGuest",
                                BusinessId = businessId,
                                DefaultCultureCode = cultureCode,
                                GuestPhones = new List<GuestPhone>
                                    {
                                        new GuestPhone
                                        {
                                            PhoneTypeCode = Model.Common.PhoneTypeEnum.Contact1,
                                            Number = "12345"
                                        }
                                    }
                            },
                            CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN },
                            IsAvailabilityIgnored = true,
                            NumberOfAdults = 1,
                            NumberOfChildren = 0,
                            RatePlanId = ratePlanToUse.Id,
                            RoomId = r.Id,
                            RoomTypeId = rt.Id,
                            BusinessId = businessId
                        };

                        Order order = new Order
                        {
                            OfflineSourceEnum = OfflineSourceEnum.Web,
                            OrderSourceCode = SourceType.Pms.GetCode(),
                            CustomerCultureCode = cultureCode,
                            CustomerCurrencyCode = ratePlanToUse.CurrencyCode,
                            GuestMessage = "what",
                            Bookings = new List<Booking>
                                {
                                    booking
                                }
                        };

                        orderManager.CreateOrder(businessId, order);
                    }
                }

                startDate = startDate.AddDays(1);
            }
        }
示例#3
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 GetRoomInformationWithRateCacheValidBusinessCallsCorrectMethods()
            {
                // Arrange
                const long BUSINESS_ID = 1;
                const int ROOM_TYPE_ID = 1;
                const string CULTURE_CODE = "en-GB";

                var roomInformationDao = MockRepository.GenerateMock<IRoomInformationDao>();
                var variantRatePlanDao = MockRepository.GenerateMock<IVariantRatePlanDao>();
                var baseRatePlanDao = MockRepository.GenerateMock<IBaseRatePlanDao>();
                var rateCacheManager = MockRepository.GenerateMock<IRateCacheManager>();

                var roomInformationManager = new RoomInformationManager
                    {
                        RoomInformationDao = roomInformationDao,
                        VariantRatePlanDao = variantRatePlanDao,
                        BaseRatePlanDao = baseRatePlanDao,
                        RateCacheManager = rateCacheManager
                    };

                var returnData = new RoomInformation
                {
                    RoomTypes = new List<RoomType>
                    {
                        new RoomType
                        {
                            Id = ROOM_TYPE_ID,
                            BusinessId = BUSINESS_ID,
                            Name = "RoomType1",
                            Rooms = new List<Room>
                            {
                                new Room
                                {
                                    Id = 1,
                                    BusinessId = 1,
                                    IsCombined = false,
                                    RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE }
                                }
                            }
                        }
                    },
                };

                var baseRatePlans = new List<BaseRatePlan>
                    {
                        new BaseRatePlan { RoomTypeId = ROOM_TYPE_ID }
                    };

                var variantRatePlans = new List<VariantRatePlan>
                    {
                        new VariantRatePlan { RoomTypeId = ROOM_TYPE_ID },
                        new VariantRatePlan { RoomTypeId = ROOM_TYPE_ID }
                    };

                roomInformationDao.Expect(r => r.GetByBusiness(BUSINESS_ID, CULTURE_CODE)).Return(returnData).Repeat.Once();
                variantRatePlanDao.Expect(v => v.GetByBusinessId(BUSINESS_ID, CULTURE_CODE)).Return(variantRatePlans).Repeat.Once();
                baseRatePlanDao.Expect(b => b.GetByBusinessId(BUSINESS_ID, CULTURE_CODE)).Return(baseRatePlans).Repeat.Once();

                rateCacheManager.Expect(r => r.GetRatesByRoomTypeIdRatePlanIdAndDateRange(Arg<long>.Is.Anything, Arg<int>.Is.Anything, Arg<int>.Is.Anything, Arg<DateTime>.Is.Anything, Arg<DateTime>.Is.Anything)).Repeat.Times(1);
                
                // Act
                roomInformationManager.GetRoomInformationWithRateCache(BUSINESS_ID, DateTime.Now, DateTime.Now.AddDays(1), CULTURE_CODE);

                // Assert
                roomInformationDao.VerifyAllExpectations();
                baseRatePlanDao.VerifyAllExpectations();
                variantRatePlanDao.VerifyAllExpectations();
                rateCacheManager.VerifyAllExpectations();
            }