예제 #1
0
            public void CheckInCheckOutInValidBookingThrowsValidationException()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();

                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 1;
                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, It.IsAny<string>()));

                try
                {
                    // Act
                    bookingManager.CheckInCheckOutBooking(BOOKING_ID, BUSINESS_ID, CheckinStatusOptions.CHECKEDIN);
                    
                    // Assert
                    Assert.Fail("An exception SRVEX30010 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30010", ex.Code, "The Validation exception is not returning the right error code");
                    bookingDao.VerifyAll();
                    // make sure order get isn't called
                    orderDao.Verify(o => o.GetByKey(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()), Times.Never);
                }
            }
예제 #2
0
            public void CheckInCheckOutValidBookingReturnsUpdatedBooking()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager { BookingDao = bookingDao.Object, OrderDao = orderDao.Object };

                var booking = BookingBuilder.SetupSimpleBooking();
                
                booking.BookingStatus = new EnumEntity {Code = BookingStatusType.CONFIRMED};
                booking.CheckinStatus = new EnumEntity {Code = CheckinStatusOptions.CHECKEDIN};
                booking.BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking;

                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);

                bookingDao.Setup(b => b.CheckInCheckOutBooking(It.Is<Booking>(book => book == booking), It.Is<EnumEntity>(ee => ee.Code == CheckinStatusOptions.CHECKEDIN), It.IsAny<string>())).Returns(booking);

                // Act
                Booking updatedBooking = bookingManager.CheckInCheckOutBooking(1, 1, CheckinStatusOptions.CHECKEDIN);

                // Assert
                Assert.AreEqual(CheckinStatusOptions.CHECKEDIN, updatedBooking.CheckinStatus.Code, "Check in status of the booking is not updated as expected.");
                bookingDao.VerifyAll();
                orderDao.VerifyAll();
            }
예제 #3
0
            public void CheckInCheckOutBookingWithInvalidStatusCodeThrowsException()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };

                Booking booking = BookingBuilder.SetupSimpleBooking();

                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);

                // Act
                try
                {
                    bookingManager.CheckInCheckOutBooking(1, 1, checkinStatusCode: "BAD");
                    // Assert
                    Assert.Fail("Validation exception not thrown for bad checkin status code");
                }
                catch (ValidationException vex)
                {
                    Assert.AreEqual("SRVEX30048", vex.Code, "validation exception code does not match");
                    bookingDao.VerifyAll();
                    orderDao.VerifyAll();
                }
                
            }