예제 #1
0
            public void ConfirmProvisionalBookingInvalidRatePlanThrowsValidationException()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };

                // Provisional booking with invalid RatePlan
                var booking = BookingBuilder.SetupSimpleBooking();
                booking.RatePlanId = null;

                var order = new Order
                {
                    Id = booking.OrderId,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    OrderSourceCode = SourceType.Pms.GetCode()
                };

                bookingDao.Setup(b => b.GetByKey(booking.Id.Value, string.Empty)).Returns(booking);
                orderDao.Setup(o => o.GetByKey(booking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                try
                {
                    // Act
                    // Call ConfirmProvisionalBooking method on BookingManager
                    bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30008 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30008", ex.Code, "The exception code thrown is not the expected.");

                    orderDao.VerifyAll();
                    bookingDao.VerifyAll();
                }
            }
예제 #2
0
            public void ConfirmProvisionalBookingWithoutBookingReferenceNumberThrowsValidationException()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };

                // Provisional booking without BookingReferenceNumber
                var booking = BookingBuilder.SetupSimpleBooking();
                booking.BookingReferenceNumber = null;

                var order = new Order
                {
                    Id = booking.OrderId
                };

                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, It.IsAny<string>())).Returns(booking);
                orderDao.Setup(o => o.GetByKey(booking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                try
                {
                    // Act
                    // Call ConfirmProvisionalBooking method on BookingManager
                    bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30030 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30030", ex.Code, "The exception code thrown is not the expected.");
                }
            }
예제 #3
0
            public void ConfirmProvisionalBookingValidNonOtaBookingSendsConfirmEmail()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = MockRepository.GenerateMock<IBookingDao>();
                var orderDao = MockRepository.GenerateMock<IOrderDao>();

                var bookingManager = new BookingManager
                {
                    BookingDao = bookingDao,
                    OrderDao = orderDao
                };


                var booking = BookingBuilder.SetupSimpleBooking(); 

                bookingDao.Expect(b => b.GetByKey(Arg<int>.Is.Equal(booking.Id), Arg<string>.Is.Anything)).Return(booking);
                bookingDao.Expect(c => c.ConfirmBooking(Arg<int>.Is.Equal(booking.Id), Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything));
                
                // Act
                // Call ConfirmProvisionalBooking method on BookingManager
                bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                // Assert
                bookingDao.VerifyAllExpectations();
                orderDao.VerifyAllExpectations();
            }
예제 #4
0
            public void ConfirmProvisionalBookingValidBookingDoesNotThrowException()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = MockRepository.GenerateMock<IBookingDao>();
                var orderDao = MockRepository.GenerateMock<IOrderDao>();
                var notificationManager = MockRepository.GenerateMock<INotificationManager>();
                CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID);
                // Invalidate the cache so we make sure our business is loaded into the cache
                Cache.Business.Invalidate();

                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao,
                        OrderDao = orderDao,
                        NotificationManager = notificationManager
                    };


                var booking = BookingBuilder.SetupSimpleBooking();
                booking.BookingScenarioType = BookingScenarioTypeEnum.PayOnArrival;
                booking.BusinessId = BUSINESS_ID;

                bookingDao.Expect(b => b.GetByKey(Arg<int>.Is.Equal(booking.Id), Arg<string>.Is.Anything)).Return(booking);
                bookingDao.Expect(c => c.ConfirmBooking(Arg<int>.Is.Equal(booking.Id), Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything));
                
                notificationManager.Expect(
                    n =>
                    n.AddPoaNotificationMessage(Arg<long>.Is.Equal(BUSINESS_ID), Arg<Booking>.Is.Equal(booking),
                                                Arg<string>.Is.Anything));
                notificationManager.Expect(
                    n => n.AddCollectPoaNotificationMessage(Arg<long>.Is.Equal(BUSINESS_ID), Arg<Booking>.Is.Equal(booking), Arg<string>.Is.Anything));

                // Act
                // Call ConfirmProvisionalBooking method on BookingManager
                bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                // Assert
                bookingDao.VerifyAllExpectations();
                orderDao.VerifyAllExpectations();
                notificationManager.VerifyAllExpectations();

                CacheHelper.ReAssignBusinessDaoToBusinessCache();
            }
예제 #5
0
            public void ConfirmProvisionalBookingWithoutEmailOrContactNumberIsSuccessful()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                
                var bookingManager = new BookingManager 
                    { 
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };
                
                // Confirm a provisional booking with a new Guest without specifying email or phone number on Guest.
                var booking = BookingBuilder.SetupSimpleBooking();
                booking.Guest.GuestPhones.Clear();
                booking.Guest.Email = null;
                
                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, It.IsAny<string>())).Returns(booking);

                // Act
                // Call ConfirmProvisionalBooking method on BookingManager
                bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                // Assert
                bookingDao.VerifyAll();
                orderDao.VerifyAll();
            }
예제 #6
0
            public void ConfirmProvisionalBookingWithNonExistantRoomIdThrowsValidationException()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;

                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var emailManager = new Mock<IEmailManager>();

                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        EmailManager = emailManager.Object,
                        OrderDao = orderDao.Object
                    };

                // Provisional booking with non existent RoomId
                var booking = BookingBuilder.SetupSimpleBooking();
                booking.RoomId = 999;
                
                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, string.Empty)).Returns(booking);
                bookingDao.Setup(b => b.ConfirmBooking(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Throws(new ExpectedResultException("SRVEX30027"));
                
                try
                {
                    // Act
                    // Call ConfirmProvisionalBooking method on BookingManager
                    bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30027 of type ExpectedResultException should have been thrown");
                }
                catch (ExpectedResultException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30027", ex.Code, "The exception code thrown is not the expected.");
                }

                bookingDao.VerifyAll();
                emailManager.Verify(x => x.SendConfirmationEmails(It.IsAny<Order>()), Times.Never);
            }