コード例 #1
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyBookingToCancelledStateThrowsValidationException()
            {
                // Arrange
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager { OrderDao = orderDao.Object };
                var guest = new Guest { Surname = "Smith", Id = 1 };
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, true);

                //Make it a cancelled booking
                updatedBooking.BookingStatus = new EnumEntity { Code = BookingStatusType.CANCELLED };
                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order { Id = updatedBooking.OrderId });
                // ACT
                try
                {
                    // Modify booking Record
                    bookingManager.ModifyBooking(false, updatedBooking);
                    //Assert
                    Assert.Fail("exception SRVEX30040 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    Assert.AreEqual("SRVEX30040", ex.Code, "The Validation exception SRVEX30040 is not returned");
                    orderDao.VerifyAll();
                }
            }
コード例 #2
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyBookingWithInvalidRateTypeThrowsValidationException()
            {
                // Arrange
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager { OrderDao = orderDao.Object };
                var guest = new Guest { Surname = "Smith", Id = 1 };
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, true);

                //Update the rate type
                updatedBooking.RateType = new EnumEntity {Code = "BAD"};
                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order { Id = updatedBooking.OrderId });

                try
                {
                    // Act
                    bookingManager.ModifyBooking(true, updatedBooking);

                    // 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");
                    orderDao.VerifyAll();
                }
            }
コード例 #3
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyExistingWLSBookingReducingCostThrowsException()
            {
                // Arrange
                var bookingManager = new BookingManager();
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();

                bookingManager.BookingDao = bookingDao.Object;
                bookingManager.OrderDao = orderDao.Object;

                var guest = new Guest { Surname = "Smith", Id = 1 };

                var originalBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                originalBooking.CancellationDetails.CancellationType = CancellationTypeEnum.NonRefundable;

                var updatedBooking = originalBooking.Clone();

                bookingDao.Setup(b => b.GetByKey(originalBooking.Id.Value, It.IsAny<string>())).Returns(originalBooking);

                orderDao.Setup(o => o.GetByKey(originalBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order { Id = originalBooking.OrderId, OrderSourceCode = SourceType.Online.GetCode(), IntegrationType = IntegrationTypeEnum.WhiteLabel });

                // Act
                try
                {
                    updatedBooking.Cost = 5;

                    // Modify booking Record
                    bookingManager.ModifyBooking(false, updatedBooking);

                    //Assert
                    Assert.Fail("exception SRVEX30145 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    Assert.AreEqual("SRVEX30145", ex.Code, "The Validation exception SRVEX30145 is not returned");
                    orderDao.VerifyAll();
                }
            }
コード例 #4
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyExistingBookingThatIsCancelledThrowsValidationException()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var bookingManager = new BookingManager { BookingDao = bookingDao.Object };
                var orderDao = new Mock<IOrderDao>();
                bookingManager.OrderDao = orderDao.Object;

                var guest = new Guest { Surname = "Smith", Id = 1 };
                var originalBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                originalBooking.BookingStatus = new EnumEntity { Code = BookingStatusType.CANCELLED };

                bookingDao.Setup(b => b.GetByKey(1, "")).Returns(originalBooking);

                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order {Id = updatedBooking.OrderId});

                //Make a simple edit of days changing
                updatedBooking.StartDate = updatedBooking.StartDate.AddDays(-1);

                // ACT
                try
                {
                    // Modify booking Record
                    bookingManager.ModifyBooking(false, updatedBooking);
                    //Assert
                    Assert.Fail("exception SRVEX30040 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    Assert.AreEqual("SRVEX30040", ex.Code, "The Validation exception SRVEX30040 is not returned");
                    bookingDao.VerifyAll();
                    orderDao.VerifyAll();
                }
            }
コード例 #5
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyExistingBookingWithEndDateEarlierThanStartDateThrowsValidationException()
            {
                // Arrange
                var bookingManager = new BookingManager();
                var orderDao = new Mock<IOrderDao>();
                bookingManager.OrderDao = orderDao.Object;

                var guest = new Guest { Surname = "Smith", Id = 1 };
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, true);

                //Make sure we set the end date earlier than the start date
                updatedBooking.EndDate = updatedBooking.StartDate.AddDays(-1);

                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order { Id = updatedBooking.OrderId });
                // ACT
                try
                {
                    // Modify booking Record
                    bookingManager.ModifyBooking(false, updatedBooking);
                    //Assert
                    Assert.Fail("exception SRVEX30002 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    Assert.AreEqual("SRVEX30002", ex.Code, "The Validation exception SRVEX30002 is not returned");
                    orderDao.VerifyAll();
                }
            }
コード例 #6
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyExistingOTABookingThrowsValidationException()
            {
                // Arrange
                var bookingManager = new BookingManager();
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();

                bookingManager.BookingDao = bookingDao.Object;
                bookingManager.OrderDao = orderDao.Object;

                var guest = new Guest { Surname = "Smith", Id = 1 };
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, false);

                bookingDao.Setup(b => b.GetByKey(updatedBooking.Id.Value, It.IsAny<string>())).Returns(updatedBooking);

                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order { Id = updatedBooking.OrderId, OrderSourceCode = SourceType.Online.GetCode(), IntegrationType = IntegrationTypeEnum.RequestResponse });

                // Act
                try
                {
                    updatedBooking.RoomTypeId = 999;

                    // Modify booking Record
                    bookingManager.ModifyBooking(false, updatedBooking);

                    //Assert
                    Assert.Fail("exception SRVEX30133 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    Assert.AreEqual("SRVEX30133", ex.Code, "The Validation exception SRVEX30133 is not returned");
                    orderDao.VerifyAll();
                }
            }
コード例 #7
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyExistingBookingWithNoIdThrowsValidationException()
            {
                // Arrange
                var bookingManager = new BookingManager();
                var orderDao = new Mock<IOrderDao>();
                bookingManager.OrderDao = orderDao.Object;

                var guest = new Guest { Surname = "Smith", Id = 1 };
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, true);

                updatedBooking.Id = null;

                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>()))
                        .Returns(new Order { Id = updatedBooking.OrderId });
                // ACT
                try
                {
                    // Modify booking Record
                    bookingManager.ModifyBooking(false, updatedBooking);
                    //Assert
                    Assert.Fail("exception SRVEX30041 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    Assert.AreEqual("SRVEX30041", ex.Code, "The Validation exception SRVEX30041 is not returned");
                    orderDao.VerifyAll();
                }
            }
コード例 #8
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyExistingBookingThatIsntAvailableWithoutForceUpdateAndCorrectInfoThrowsException()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var availabilityManager = new Mock<IAvailabilityManager>();
                var orderDao = new Mock<IOrderDao>();

                var bookingManager = new BookingManager
                                                    {
                                                        BookingDao = bookingDao.Object,
                                                        AvailabilityManager = availabilityManager.Object,
                                                        OrderDao = orderDao.Object
                                                    };

                var guest = new Guest { Surname = "Smith", Id = 1 };
                bookingDao.Setup(b => b.GetByKey(1, It.IsAny<string>()))
                          .Returns(BookingBuilder.SetupSimpleBooking(guest, false));

                // update that changes the start / end date
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                updatedBooking.StartDate = new DateTime(2020, 4, 1, 0, 0, 0, DateTimeKind.Utc);
                updatedBooking.EndDate = new DateTime(2020, 6, 2, 0, 0, 0, DateTimeKind.Utc);

                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(new Order
                                                                                             {
                                                                                                 Id = updatedBooking.OrderId
                                                                                             });
                
                // Tell it to return no availability
                availabilityManager.Setup(am => am.CheckAvailabilityForBookingModify(updatedBooking, It.IsAny<string>())).Returns(
                    new AvailabilitySearchResult() { UnavailabilityReasonCode = UnavailabilityReasonCode.NoInventory });

                // ACT
                try
                {
                    // Modify booking record, don't force update
                    bookingManager.ModifyBooking(false, updatedBooking);
                    // ASSERT
                    Assert.Fail("Validation Exception with code SRVEX30042 was not thrown");
                }
                catch (ValidationException ve)
                {
                    Assert.AreEqual("SRVEX30042", ve.Code, "Validation exception with the wrong code was thrown.");
                    bookingDao.VerifyAll();
                    availabilityManager.VerifyAll();
                    orderDao.VerifyAll();
                }
            }
コード例 #9
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyBookingThatIsUnavailableWithNoRateDefinedStillUpdatedIsSuccessful(UnavailabilityReasonCode validReason)
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var availabilityManager = new Mock<IAvailabilityManager>();
                var orderDao = new Mock<IOrderDao>();

                var bookingManager = new BookingManager
                                                    {
                                                        BookingDao = bookingDao.Object,
                                                        AvailabilityManager = availabilityManager.Object,
                                                        OrderDao = orderDao.Object
                                                    };

                var guest = new Guest { Surname = "Smith", Id = 1 };
                bookingDao.Setup(b => b.GetByKey(1, It.IsAny<string>())).Returns(BookingBuilder.SetupSimpleBooking(guest, false));
                // update that changes the start date
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                updatedBooking.StartDate = updatedBooking.StartDate.AddDays(-1);
                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = updatedBooking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                
                bookingDao.Setup(x => x.Modify(updatedBooking, It.Is<Order>(o => o.Id == order.Id)));
                
                // mock up that it shows as not available with reason code NoRateDefined
                var mockSearchResult = AvailabilitySearchResultBuilder.GetSimpleAvailabilitySearchResult(1, false, validReason);

                availabilityManager.Setup(am => am.CheckAvailabilityForBookingModify(updatedBooking, order.CustomerCurrencyCode)).Returns(mockSearchResult);

                // ACT
                // Modify booking record, force update
                var modifyResult = bookingManager.ModifyBooking(false, updatedBooking);

                // ASSERT
                Assert.IsNotNull(modifyResult, "Modify was not successful");
                bookingDao.VerifyAll();
                availabilityManager.VerifyAll();
                orderDao.VerifyAll();
            }
コード例 #10
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyProvisionalBookingThatIsntAvailableWithForceUpdateAndCorrectInfoIsSuccessful()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();

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

                var guest = new Guest { Surname = "Smith", Id = 1 };
                var booking = BookingBuilder.SetupSimpleBooking(guest, false);
                
                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = booking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                bookingDao.Setup(b => b.GetByKey(booking.Id.Value, 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);

                // update that changes the start / end date
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                updatedBooking.StartDate = new DateTime(2020, 4, 1, 0, 0, 0, DateTimeKind.Utc);
                updatedBooking.EndDate = new DateTime(2020, 6, 2, 0, 0, 0, DateTimeKind.Utc);

                bookingDao.Setup(x => x.Modify(updatedBooking, It.Is<Order>(o => o.Id == order.Id)));

                // ACT
                // Modify booking record, force update
                var modifyResult = bookingManager.ModifyBooking(true, updatedBooking);

                // ASSERT
                Assert.IsNotNull(modifyResult, "Modify was not successful");
                bookingDao.VerifyAll();
                orderDao.VerifyAll();
            }
コード例 #11
0
ファイル: BookingManagerTest.cs プロジェクト: ognjenm/egle
            public void ModifyBookingWithCorrectInfoIsSuccessful()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var availabilityManager = new Mock<IAvailabilityManager>();
                var orderDao = new Mock<IOrderDao>();
                var bookingStatus = BookingStatusType.CONFIRMED;

                var bookingManager = new BookingManager
                                         {
                                             BookingDao = bookingDao.Object,
                                             AvailabilityManager = availabilityManager.Object,
                                             OrderDao = orderDao.Object
                                         };

                AvailabilitySearchResult mockSearchResult = AvailabilitySearchResultBuilder.GetSimpleAvailabilitySearchResult(1, true);

                var guest = new Guest
                {
                    Surname = "Smith",
                    Id = 1,
                    GuestPhones = new List<GuestPhone>
                    {
                        new GuestPhone {PhoneTypeCode = PhoneTypeEnum.Contact1, Number = "07123456789"}
                    }
                };
                var booking = BookingBuilder.SetupSimpleBooking(guest);
                booking.BookingStatus = new EnumEntity {Code = bookingStatus};
                booking.StartDate = new DateTime(2020, 5, 1, 0, 0, 0, DateTimeKind.Utc);
                booking.EndDate = new DateTime(2020, 5, 2, 0, 0, 0, DateTimeKind.Utc);
                
                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = booking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                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.GetByKey(booking.Id.Value, It.IsAny<string>())).Returns(booking);

                // update that changes the start / end date
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest);
                updatedBooking.BookingStatus = new EnumEntity { Code = bookingStatus };
                updatedBooking.StartDate = new DateTime(2020, 4, 1, 0, 0, 0, DateTimeKind.Utc);
                updatedBooking.EndDate = new DateTime(2020, 6, 2, 0, 0, 0, DateTimeKind.Utc); 
                
                bookingDao.Setup(x => x.Modify(updatedBooking, order));
                
                //Make sure it calls to make existing available before making the new unavailable
                availabilityManager.Setup(am => am.CheckAvailabilityForBookingModify(It.Is<Booking>(b => b.Id == booking.Id), order.CustomerCurrencyCode))
                                   .Returns(mockSearchResult);

                // Act: Modify booking record
                Booking modifyResult = bookingManager.ModifyBooking(false, updatedBooking);

                // Assert
                Assert.IsNotNull(modifyResult, "Modify was not successful");
                bookingDao.VerifyAll();
                availabilityManager.VerifyAll();
                orderDao.VerifyAll();
            }