Esempio n. 1
0
            public void CreateEditVariantRatePlansWithInvalidVariantAmountThrowsException()
            {
                // Arrange
                const int variantRatePlanId = 1;
                const int variantRatePlanRateId = 0;
                const int roomTypeId = 1;
                const long businessId = 1;
                const int baseRatePlanId = 1;
                const decimal rackRate = 30;
                const decimal rate = 40;
                const decimal variantRate = -50;

                var baseRatePlanDao = new Mock<IBaseRatePlanDao>();
                var baseRatePlanRatesDao = new Mock<IBaseRatePlanRatesDao>();

                var variantRatePlan = new VariantRatePlan { Id = variantRatePlanId, VariantRatePlanRateId = variantRatePlanRateId, RoomTypeId = roomTypeId, BusinessId = businessId, VariantType = new VariantType { Type = VariantTypeEnum.Amount }, VariantAmount = variantRate };
                var baseRatePlan = new BaseRatePlan { Id = baseRatePlanId, SellAtRackRate = true, RackRate = rackRate };
                var ratePlanRate = new RatePlanRate { MonRate = rate, TueRate = rate, WedRate = rate, ThuRate = rate, FriRate = rate, SatRate = rate, SunRate = rate };

                var ratePlanManager = new RatePlanManager
                {
                    BaseRatePlanDao = baseRatePlanDao.Object,
                    BaseRatePlanRatesDao = baseRatePlanRatesDao.Object
                };

                baseRatePlanDao.Setup(brp => brp.GetByRoomTypeId(roomTypeId, businessId, string.Empty)).Returns(baseRatePlan);
                baseRatePlanRatesDao.Setup(brp => brp.GetByRatePlanId(baseRatePlanId)).Returns(new List<RatePlanRate> { ratePlanRate });
                
                try
                {
                    // Act
                    ratePlanManager.CreateEditVariantRatePlans(new List<VariantRatePlan> { variantRatePlan });

                    // Assert
                    Assert.Fail("Validation exception was not thrown");
                }
                catch (ValidationException vex)
                {
                    Assert.AreEqual(Errors.SRVEX30142.ToString(), vex.Code, "Incorrect validation exception was thrown");
                }
            }
Esempio n. 2
0
            public void CreateEditVariantRatePlansForExistingRatePlanAndSelectedSeasonExpectRatePlanModified()
            {
                // Arrange
                const int variantRatePlanId = 1;
                const int variantRatePlanRateId = 0;
                const int roomTypeId = 1;
                const long businessId = 1;
                const int baseRatePlanId = 1;
                const decimal rackRate = 30;
                const decimal rate = 40;

                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var variantRatePlanDao = new Mock<IVariantRatePlanDao>();
                var baseRatePlanDao = new Mock<IBaseRatePlanDao>();
                var baseRatePlanRatesDao = new Mock<IBaseRatePlanRatesDao>();
                var promotionManagerMock = new Mock<IPromotionManager>();

                var variantRatePlan = new VariantRatePlan { Id = variantRatePlanId, VariantRatePlanRateId = variantRatePlanRateId, RoomTypeId = roomTypeId, BusinessId = businessId, VariantType = new VariantType { Type = VariantTypeEnum.Percentage } };
                var baseRatePlan = new BaseRatePlan { Id = baseRatePlanId, SellAtRackRate = true, RackRate = rackRate };
                var ratePlanRate = new RatePlanRate { MonRate = rate, TueRate = rate, WedRate = rate, ThuRate = rate, FriRate = rate, SatRate = rate, SunRate = rate };
                
                var ratePlanManager = new RatePlanManager
                    {
                        EventTrackingManager = eventTrackingManager.Object,
                        VariantRatePlanDao = variantRatePlanDao.Object,
                        BaseRatePlanDao = baseRatePlanDao.Object,
                        BaseRatePlanRatesDao = baseRatePlanRatesDao.Object,
                        PromotionManager = promotionManagerMock.Object
                    };

                baseRatePlanDao.Setup(brp => brp.GetByRoomTypeId(roomTypeId, businessId, string.Empty)).Returns(baseRatePlan);
                baseRatePlanRatesDao.Setup(brp => brp.GetByRatePlanId(baseRatePlanId)).Returns(new List<RatePlanRate> { ratePlanRate });
                promotionManagerMock.Setup(pr => pr.UpsertPromotionRatePlanLinks(It.IsAny<RatePlan>()));

                variantRatePlanDao.Setup(vrp => vrp.Modify(variantRatePlan));

                eventTrackingManager.Setup(e => e.CreateBusinessEventAsync(It.IsAny<long>(), It.IsAny<BusinessEventTypesEnum>(), It.IsAny<string>(), null));
               
                // Act 
                ratePlanManager.CreateEditVariantRatePlans(new List<VariantRatePlan> { variantRatePlan });

                // Assert
                variantRatePlanDao.VerifyAll();
                eventTrackingManager.Verify(e => e.CreateBusinessEventAsync(It.IsAny<long>(), BusinessEventTypesEnum.VariantRatePlanModified, It.IsAny<string>(), null), Times.Once);
                baseRatePlanDao.VerifyAll();
                promotionManagerMock.Verify(pr => pr.UpsertPromotionRatePlanLinks(It.IsAny<RatePlan>()), Times.AtLeastOnce());
            }