public void GetByEventKeyReturnsBookingEventData() { // Arrange const long businessId = 1; // First get a booking and then event and finally the event data int searchCriteria = 0; const int MAX_ITERATIONS = 1000; var bookings = bookingDao.FindByPartialBookingReference(businessId, searchCriteria.ToString(), 1); while ((bookings == null || bookings.Any() == false) && searchCriteria < MAX_ITERATIONS) { searchCriteria++; bookings = bookingDao.FindByPartialBookingReference(businessId, searchCriteria.ToString(), 1); } // modify booking so data is created var booking = bookingDao.GetByReference(bookings[0].BookingReferenceNumber); booking.Notes = "new notes"; var orderManager = new OrderManager(); var order = orderManager.GetByKey(booking.OrderId); bookingDao.Modify(booking, order); var bookingEvents = bookingEventDao.GetByBookingKey(booking.Id.Value); var eventId = bookingEvents.First(be => be.EventType.Code == BookingEventType.Modified.GetCode()).Id; // Act var bookingEventData = bookingEventDataDao.GetAllByEventId(eventId); // Assert Assert.IsNotNull(bookingEventData, "booking event data was null"); Assert.IsNotEmpty(bookingEventData, "booking event data list was empty"); Assert.IsTrue(bookingEventData.TrueForAll(bed => bed.BookingEventId == eventId), "A booking event data was returned with mismatched event id"); Assert.IsTrue(bookingEventData.Exists(bed => string.Equals(bed.ColumnName, BookingMapper.Parameters.Notes.ToString(), StringComparison.InvariantCultureIgnoreCase)), "Notes did not show as modified"); }
/// <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); } }
protected override void RunBeforeAllTests() { base.RunBeforeAllTests(); var businessManager = new BusinessManager(); var roomTypeManager = new RoomTypeManager(); var roomManager = new RoomManager(); var orderManager = new OrderManager(); //Create a business var paymentMethod = new BusinessPaymentMethod { BusinessId = BUSINESS_ID, CurrencyCode = CURRENCY, PaymentMethodCode = PaymentMethodEnum.Cash.GetCode() }; var provider = new Provider { RoomCount = ROOM_COUNT, ContentId = BUSINESS_ID.ToString(), ProviderTypeCode = PROVIDER_TYPE, }; var business = new Model.Business.Business { BusinessStatusCode = "A", BusinessTypeCode = "P", Name = "Test Business", ShortName = "Test", ReferenceCode = "B001", IsTaxRegistered = true, TaxRegistrationNumber = "12345", BusinessRegistrationNumber = "12345", AddressLine1 = "5 Main Road", AddressLine2 = "Twickenham", City = "London", StateProvinceId = 386, PostCode = "TW2 5SE", CountryId = 16, BusinessTelephoneNumber = "07448752114", TimeZoneId = 36, DefaultCultureCode = CULTURE, WorkingCurrencyCode = CURRENCY, UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"), Provider = provider, BusinessPaymentMethods = new List<BusinessPaymentMethod> {paymentMethod} }; var businessId = businessManager.CreateBusiness(business); // Create a room type var ratePlan = new BaseRatePlan { BusinessId = businessId, CurrencyCode = CURRENCY, MaxAdults = 2, MaxChildren = 2, MaxOccupancy = 3, BoardBasis = new EnumEntity {Code = "BK"}, CancellationClass = new EnumEntity {Code = "FR"}, RackRate = new decimal(120.0), SellAtRackRate = true, RatePlanType = new RatePlanType {Type = RatePlanTypeEnum.Base}, Rates = new RatePlanRate{BusinessId = businessId, MonRate = 120, MonMinStay = 120}, UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"), }; var roomType = new RoomType { BusinessId = businessId, RoomClass = roomTypeManager.GetRoomClasses(CULTURE).FirstOrDefault(), //new RoomClass { Code = "DBL" }, QualityType = roomTypeManager.GetQualityTypes(CULTURE).FirstOrDefault(), //new QualityType { Code = "APT" }, BathroomType = roomTypeManager.GetBathroomTypes(CULTURE).FirstOrDefault(), //new BathroomType { Code = "SP" }, Code = "DBL99", ServiceFrequency = new EnumEntity { Code = "B" }, UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"), BaseRatePlan = ratePlan, BaseRatePlanId = ratePlan.Id, Aspect = new Aspect { Code = "BAL"}, }; roomTypeManager.CreateRoomTypeAndBaseRatePlan(roomType); roomType = roomTypeManager.GetRoomTypesAndBaseRatePlans(businessId, CULTURE).First(); ratePlan = roomType.BaseRatePlan; //Create a room var roomId = roomManager.CreateRoom("TestRoom", roomType.Id, businessId); //Create an order var booking = new Booking { BusinessId = businessId, Guest = new Guest { DefaultCultureCode = CULTURE, Surname = "TestSurname", BusinessId = businessId }, StartDate = new DateTime(2014, 2, 10, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2014, 2, 12, 0, 0, 0, DateTimeKind.Utc), NumberOfAdults = 2, NumberOfChildren = 1, Cost = new decimal(120.5), BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED }, RoomTypeId = roomType.Id, RoomId = roomId, RatePlanId = ratePlan.Id, Notes = "Testing note", BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking, RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE }, CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN }, IsAvailabilityIgnored = true, BoardBasis = BoardBasisTypeEnum.BreakfastIncluded, CancellationDetails = new CancellationDetail() }; var order = new Order { OfflineSourceEnum = OfflineSourceEnum.Web, OrderSourceCode = SourceType.Pms.GetCode(), CustomerCurrencyCode = CURRENCY, Bookings = new List<Booking> { booking }, CustomerCultureCode = "en-GB" }; // Mock email manager so it doesn't send emails var emailManager = new Mock<IEmailManager>(); orderManager.EmailManager = emailManager.Object; emailManager.Setup(x => x.SendConfirmationEmails(order)).Returns(true); orderManager.CreateOrder(businessId, order); }