public void RequestCancelExistingBookingIsSuccessful() { // Arrange var bookingDao = new Mock<IBookingDao>(); var emailManagerMock = new Mock<IEmailManager>(); var orderDao = new Mock<IOrderDao>(); var bookingManager = new BookingManager { BookingDao = bookingDao.Object, EmailManager = emailManagerMock.Object, OrderDao = orderDao.Object }; var requestCancelBooking = new RequestCancelBooking { BookingId = 1, BusinessContactedGuest = true, CancellationRequestAction = CancellationRequestAction.ChargedFullBookingValue, CancellationRequestReason = CancellationReasonEnum.CardDeclined, Notes = "unit test notes" }; var order = new Order { Id = 1, OrderSourceCode = SourceType.Online.GetCode(), IntegrationType = IntegrationTypeEnum.Push }; orderDao.Setup(o => o.GetByKey(It.Is<int>(i => i == order.Id), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order); bookingDao.Setup(c => c.RequestCancelBooking(requestCancelBooking)).Returns(true); emailManagerMock.Setup(e => e.SendCancellationRequestEmail(requestCancelBooking, It.IsAny<Booking>(), It.Is<Order>(o => o.Id == order.Id))).Returns(true); //Act bookingManager.RequestCancelBooking(requestCancelBooking, new Booking { Id = 1, OrderId = 1 }); // Assert bookingDao.VerifyAll(); emailManagerMock.VerifyAll(); orderDao.VerifyAll(); }
public void RequestCancelNonExistentBooking_ExpectExceptionThrown() { // Arrange var bookingManager = new BookingManager(); var requestCancelBooking = new RequestCancelBooking() {BookingId = -1}; try { // Act bookingManager.RequestCancelBooking(requestCancelBooking, new Booking()); // Assert Assert.Fail("An exception SRVEX30095 of type ValidationException should have been thrown"); } catch (ExpectedResultException ex) { // Assert Assert.AreEqual("SRVEX30095", ex.Code, "The exception code thrown is not the expected."); } }