public void CreateBookingNoEmailAndSendConfirmationEmailCheckedThrowsValidationException() { // Arrange var bookingManager = new BookingManager { BookingDao = MockRepository.GenerateStub<IBookingDao>() }; var booking = new Booking { BusinessId = 1, OrderId = 1, Guest = new Guest { Id = 23, Surname = "Test Guest", IsConfirmationEmailToBeSent = true }, StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc), NumberOfAdults = 2, NumberOfChildren = 1, Cost = new decimal(120.5), BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED }, RoomTypeId = 1, RoomId = 1, RatePlanId = 1, Notes = "Testing note", RateType = new EnumEntity { Code = "BAR" }, BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking }; var order = new Order { OfflineSourceEnum = OfflineSourceEnum.Web, Id = booking.OrderId, OrderSourceCode = SourceType.Online.GetCode(), CustomerCurrencyCode = "GBP" }; try { // Act bookingManager.CreateBooking(booking, order); // Assert Assert.Fail("An exception of type ValidationException should have been thrown"); } catch (ValidationException ex) { // Assert Assert.AreEqual("SRVEX30110", ex.Code, "The Validation exception is not returning the right error code"); } }
public void CreateBookingWithInvalidRateTypeThrowsValidationException() { // Arrange var bookingManager = new BookingManager(); var booking = new Booking { BusinessId = 1, Guest = new Guest {Id = 23, Surname = "Test Guest", Email = "*****@*****.**"}, StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc), NumberOfAdults = 2, NumberOfChildren = 1, Cost = new decimal(120.5), BookingStatus = new EnumEntity {Code = BookingStatusType.CONFIRMED}, RoomTypeId = 1, RoomId = 1, RatePlanId = 1, Notes = "Testing note", RateType = new EnumEntity {Code = "BAD"}, BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking }; var order = new Order { OfflineSourceEnum = OfflineSourceEnum.Web, Id = booking.OrderId, OrderSourceCode = SourceType.Online.GetCode(), CustomerCurrencyCode = "GBP" }; try { // Act bookingManager.CreateBooking(booking, order); // Assert Assert.Fail("An exception of type ValidationException should have been thrown"); } catch (ValidationException ex) { // Assert Assert.AreEqual("SRVEX30046", ex.Code, "The Validation exception is not returning the right error code"); } }
public void CreateBookingWithSendConfirmationEmailUncheckedDoesNotEmailConfirmation() { // Arrange var bookingDao = new Mock<IBookingDao>(); var orderDao = new Mock<IOrderDao>(); var emailManager = new Mock<IEmailManager>(); var guestManager = new Mock<IGuestManager>(); var cancellationPoliciesManager = new Mock<ICancellationPoliciesManager>(); var bookingManager = new BookingManager { EmailManager = emailManager.Object, BookingDao = bookingDao.Object, OrderDao = orderDao.Object, GuestManager = guestManager.Object, CancellationPoliciesManager = cancellationPoliciesManager.Object }; var booking = new Booking { BusinessId = 1, OrderId = 1, Guest = new Guest { Id = 23, Surname = "Test Guest", Email = "*****@*****.**", IsConfirmationEmailToBeSent = false }, StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc), NumberOfAdults = 2, NumberOfChildren = 1, Cost = new decimal(120.5), BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED }, RoomTypeId = 1, RoomId = 1, RatePlanId = 1, Notes = "Testing note", BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking, RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE } }; var order = new Order { OfflineSourceEnum = OfflineSourceEnum.Web, Id = booking.OrderId, OrderSourceCode = SourceType.Online.GetCode(), CustomerCurrencyCode = "GBP" }; bookingDao.Setup(b => b.Create(booking, order)).Callback(delegate { booking.Id = 1; }); cancellationPoliciesManager.Setup(cm => cm.GetRatePlanCancellationRule(It.IsAny<CancellationPolicyRequest>(), booking.RatePlanId)).Returns(new CancellationRule()); // Act bookingManager.CreateBooking(booking, order); // Assert bookingDao.VerifyAll(); orderDao.VerifyAll(); emailManager.Verify(e => e.SendConfirmationEmails(It.IsAny<Order>()), Times.Never()); }
public void CreateBookingInvalidStartEndDateThrowsValidationException() { // Arrange var bookingDao = new Mock<IBookingDao>(); var bookingManager = new BookingManager { BookingDao = bookingDao.Object }; var booking = new Booking { OrderId = 5, BusinessId = 1, Guest = new Guest { Id = 23, Surname = "Test Guest", Email = "*****@*****.**" }, StartDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), NumberOfAdults = 2, NumberOfChildren = 1, Cost = new decimal(120.5), BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED }, RoomTypeId = 1, RoomId = 1, RatePlanId = 1, Notes = "Testing note", BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking }; var order = new Order { OfflineSourceEnum = OfflineSourceEnum.Web, Id = booking.OrderId, OrderSourceCode = SourceType.Online.GetCode(), CustomerCurrencyCode = "GBP" }; bookingManager.BookingDao = bookingDao.Object; try { // Act bookingManager.CreateBooking(booking, order); // Assert Assert.Fail("An exception SRVEX30002 of type ValidationException should have been thrown"); } catch (ValidationException ex) { // Assert Assert.AreEqual("SRVEX30002", ex.Code, "The Validation exception is not returning the right error code"); bookingDao.Verify(b => b.Create(booking, order), Times.Never); } // Make sure this is reset for future tests bookingManager.BookingDao = new BookingDao(); }