示例#1
0
            public void DeleteRatePlanRatesCallsCorrectMethodsAndRaisesEvent()
            {
                //Arrange
                var ratePlanRateDao = new Mock<IBaseRatePlanRatesDao>();
                var variantRatePlanDao = new Mock<IVariantRatePlanDao>();
                var eventTrackingManager = new Mock<IEventTrackingManager>();
                const long BUSINESS_ID = 5;
                const int ROOMTYPE_ID = 2;

                ratePlanRateDao.Setup(rpr => rpr.DeleteBaseRatePlanRates(BUSINESS_ID, ROOMTYPE_ID));
                ratePlanRateDao.Setup(rpr => rpr.DeleteBaseRatePlanOccupantRates(BUSINESS_ID, ROOMTYPE_ID));
                variantRatePlanDao.Setup(vrp => vrp.DeleteVariantRatePlanRates(BUSINESS_ID, ROOMTYPE_ID));
                eventTrackingManager.Setup(et => et.CreateBusinessEventAsync(BUSINESS_ID, Model.Business.BusinessEventTypesEnum.RatePlanRatesCleared, ROOMTYPE_ID.ToString(), null));

                RatePlanManager manager = new RatePlanManager
                {
                    RatePlanRateDao = ratePlanRateDao.Object,
                    VariantRatePlanDao = variantRatePlanDao.Object,
                    EventTrackingManager = eventTrackingManager.Object
                };

                manager.DeleteRatePlanRates(BUSINESS_ID, ROOMTYPE_ID);

                ratePlanRateDao.VerifyAll();
                variantRatePlanDao.VerifyAll();
                eventTrackingManager.VerifyAll();
            }
示例#2
0
            public void GetCancellationClassesIsSuccessful()
            {
                // Arrange
                const string CULTURE_CODE = "en-GB";

                var ratePlanDao = new Mock<IRatePlanDao>();
                var ratePlanManager = new RatePlanManager { RatePlanDao = ratePlanDao.Object };

                ratePlanDao.Setup(x => x.GetCancellationClasses(CULTURE_CODE)).Returns(new List<CancellationClass>());

                // Act
                ratePlanManager.GetCancellationClasses(CULTURE_CODE);

                // Assert
                ratePlanDao.VerifyAll();
            }
示例#3
0
            public void GetBoardBasesIsSuccessful()
            {
                // Arrange
                const string CULTURE_CODE = "en-GB";

                var ratePlanDao = MockRepository.GenerateMock<IRatePlanDao>();
                var ratePlanManager = new RatePlanManager { RatePlanDao = ratePlanDao };

                ratePlanDao.Expect(x => x.GetBoardBases(CULTURE_CODE)).Return(new List<BoardBasis>());

                // Act
                ratePlanManager.GetBoardBases(CULTURE_CODE);

                // Assert
                ratePlanDao.VerifyAllExpectations();
            }
示例#4
0
            public void ModifyVariantRatePlanIsSuccessful()
            {
                // Arrange
                const int ratePlanId = 1;
                const long businessId = 1;
                const int ratePlanRateId = 5;

                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var variantRatePlanDao = new Mock<IVariantRatePlanDao>();
                
                var ratePlanManager = new RatePlanManager
                {
                    EventTrackingManager = eventTrackingManager.Object,
                    VariantRatePlanDao = variantRatePlanDao.Object
                };
                
                var ratePlan = new VariantRatePlan { BusinessId = businessId, Id = ratePlanId, RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Variant }, Rates = new RatePlanRate { Id = ratePlanRateId, RatePlanId = ratePlanId } };

                variantRatePlanDao.Setup(rp => rp.Modify(ratePlan));

                eventTrackingManager.Setup(e => e.CreateBusinessEventAsync(It.IsAny<long>(), It.IsAny<BusinessEventTypesEnum>(), It.IsAny<string>(), null));
                
                // Act
                ratePlanManager.ModifyVariantRatePlan(ratePlan);

                // Assert
                variantRatePlanDao.VerifyAll();
                eventTrackingManager.Verify(e => e.CreateBusinessEventAsync(It.IsAny<long>(), BusinessEventTypesEnum.VariantRatePlanModified, It.IsAny<string>(), null), Times.Once);
            }
示例#5
0
            public void ModifyRatePlanRateNullReturnsNull()
            {
                // Arrange
                var businessEventDao = MockRepository.GenerateMock<IBusinessEventDao>();
                var ratePlanRateDao = MockRepository.GenerateStrictMock<IBaseRatePlanRatesDao>();
                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    BusinessEventDao = businessEventDao,
                    RatePlanRateDao = ratePlanRateDao
                };

                ratePlanRateDao.Expect(rp => rp.Modify(Arg<RatePlanRate>.Is.Anything)).Repeat.Never();

                businessEventDao.Expect(be => be.Create(Arg<BusinessEvent>.Is.Anything)).Repeat.Never();

                // Act
                var result = ratePlanManager.ModifyRatePlanRates(null);

                // Assert
                Assert.IsNull(result, "Null was not returned");
                ratePlanRateDao.VerifyAllExpectations();
                businessEventDao.VerifyAllExpectations();
            }
示例#6
0
            public void ModifyRatePlanRateNoRatePlanIdThrowsException()
            {
                // Arrange
                var businessEventDao = MockRepository.GenerateMock<IBusinessEventDao>();
                var ratePlanRateDao = MockRepository.GenerateStrictMock<IBaseRatePlanRatesDao>();
                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    BusinessEventDao = businessEventDao,
                    RatePlanRateDao = ratePlanRateDao
                };

                const long BUSINESS_ID = 1;
                const int RATE_PLAN_RATE_ID = 5;

                var ratePlanRate = new RatePlanRate { BusinessId = BUSINESS_ID, Id = RATE_PLAN_RATE_ID };

                ratePlanRateDao.Expect(rp => rp.Modify(Arg<RatePlanRate>.Is.Anything)).Repeat.Never();

                businessEventDao.Expect(be => be.Create(Arg<BusinessEvent>.Is.Anything)).Repeat.Never();

                try
                {
                    // Act
                    ratePlanManager.ModifyRatePlanRates(ratePlanRate);

                    // Assert
                    Assert.Fail("Validation exception was not thrown");
                }
                catch (ValidationException vex)
                {
                    Assert.AreEqual(Errors.SRVEX30098.ToString(), vex.Code, "Incorrect validation exception was thrown");
                    ratePlanRateDao.VerifyAllExpectations();
                    businessEventDao.VerifyAllExpectations();
                }
            }
示例#7
0
            public void ModifyRatePlanRateIsSuccessful()
            {
                // Arrange
                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var ratePlanRateDao = new Mock<IBaseRatePlanRatesDao>();

                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    RatePlanRateDao = ratePlanRateDao.Object,
                    EventTrackingManager = eventTrackingManager.Object
                };

                const int RATE_PLAN_ID = 1;
                const long BUSINESS_ID = 1;
                const int RATE_PLAN_RATE_ID = 5;

                var ratePlanRate = new RatePlanRate { BusinessId = BUSINESS_ID, Id = RATE_PLAN_RATE_ID, RatePlanId = RATE_PLAN_ID };

                ratePlanRateDao.Setup(rp => rp.Modify(It.Is<RatePlanRate>(rpr => rpr.Id == RATE_PLAN_RATE_ID && rpr.BusinessId == BUSINESS_ID && rpr.RatePlanId == RATE_PLAN_ID)));

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RatePlanRateModified, ratePlanRate.Id.ToString(CultureInfo.InvariantCulture), null));

                // Act
                ratePlanManager.ModifyRatePlanRates(ratePlanRate);

                // Assert
                ratePlanRateDao.VerifyAll();
                eventTrackingManager.VerifyAll();
            }
示例#8
0
            public void CreateEditBaseRatePlanRatesForEvergreenRatePlanExpectRatePlanToBeCreated()
            {
                // Arrange
                const int RATE_PLAN_ID = 1;
                const long BUSINESS_ID = 1;

                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var ratePlanRateDao = new Mock<IBaseRatePlanRatesDao>();
                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    EventTrackingManager = eventTrackingManager.Object,
                    RatePlanRateDao = ratePlanRateDao.Object
                };

                var ratePlanRate = new RatePlanRate { BusinessId = BUSINESS_ID, Id = 0, RatePlanId = RATE_PLAN_ID, PeriodId = null, OccupancyRateType = OccupancyRateType.Base};
                var ratePlanRates = new List<RatePlanRate>() { ratePlanRate };
                ratePlanRateDao.Setup(rp => rp.Create(It.Is<RatePlanRate>(rpr => rpr.Id == 0 && rpr.BusinessId == BUSINESS_ID && rpr.RatePlanId == RATE_PLAN_ID)));

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RatePlanAdded, RATE_PLAN_ID.ToString(CultureInfo.InvariantCulture), null));

                // Act
                ratePlanManager.CreateEditBaseRatePlanRates(ratePlanRates);

                // Assert
                ratePlanRateDao.VerifyAll();
                eventTrackingManager.VerifyAll();
            }
示例#9
0
            public void CreateBaseRatePlanRatesMlosHasToBeZeroWhenPriceIsZeroFails()
            {
                // Arrange
                var ratePlanRateDao = MockRepository.GenerateMock<IBaseRatePlanRatesDao>();
                var ratePlanManager = new RatePlanManager { RatePlanRateDao = ratePlanRateDao };

                const int RATE_PLAN_ID = 1;
                var rates = new RatePlanRate
                                {
                                    RatePlanId = RATE_PLAN_ID,
                                    MonMinStay = 1,
                                    MonRate = new decimal(10),
                                    TueMinStay= 1,
                                    TueRate = new decimal(10),
                                    WedMinStay = 1,
                                    WedRate = new decimal(10),
                                    ThuMinStay = 1,
                                    ThuRate = new decimal(10),
                                    FriMinStay = 1,
                                    FriRate = new decimal(10),
                                    SatMinStay = 1,
                                    SatRate = new decimal(10),
                                    SunMinStay = 2,
                                    SunRate = 0,
                               };

                var ratePlan = new BaseRatePlan { Rates = rates, RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Base } };

                // Act
                ratePlanManager.CreateBaseRatePlan(ratePlan);
            }
示例#10
0
            public void CreateBaseRatePlanIsSuccessful()
            {
                // Arrange
                var ratePlanRateDao = new Mock<IBaseRatePlanRatesDao>();
                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var ratePlanDao = new Mock<IBaseRatePlanDao>();
                var ratePlanManager = new RatePlanManager { RatePlanRateDao = ratePlanRateDao.Object, 
                                                            EventTrackingManager = eventTrackingManager.Object, 
                                                            BaseRatePlanDao = ratePlanDao.Object };
                
                const int RATE_PLAN_ID = 1;
                const long BUSINESS_ID = 1;
                var rates = new RatePlanRate
                                {
                                    RatePlanId = RATE_PLAN_ID,
                                    MonMinStay = 1,
                                    MonRate = new decimal(10),
                                    TueMinStay= 1,
                                    TueRate = new decimal(10),
                                    WedMinStay = 1,
                                    WedRate = new decimal(10),
                                    ThuMinStay = 1,
                                    ThuRate = new decimal(10),
                                    FriMinStay = 1,
                                    FriRate = new decimal(10),
                                    SatMinStay = 1,
                                    SatRate = new decimal(10),
                                    SunMinStay = 1,
                                    SunRate = new decimal(10),
                               };

                var ratePlan = new BaseRatePlan { BusinessId = BUSINESS_ID, Rates = rates, RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Base } };

                ratePlanDao.Setup(rp => rp.Create(ratePlan)).Callback(delegate { ratePlan.Id = RATE_PLAN_ID; });

                int id = 2;

                ratePlanRateDao.Setup(x => x.Create(rates)).Callback(delegate { rates.Id = id; });
                eventTrackingManager.Setup(
                    be =>
                    be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RatePlanAdded,
                                           RATE_PLAN_ID.ToString(CultureInfo.InvariantCulture), null));

                eventTrackingManager.Setup(
                    be =>
                    be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RatePlanRateAdded,
                                           id.ToString(CultureInfo.InvariantCulture), null));

                // Act
                ratePlanManager.CreateBaseRatePlan(ratePlan);

                // Assert
                ratePlanRateDao.VerifyAll();
                eventTrackingManager.VerifyAll();
                ratePlanDao.VerifyAll();
            }
示例#11
0
            public void GetVariantRatePlansIncludeSeasonEventPeriodsRatePlanList()
            {
                //Arrange
                const string DEFAULT_CULTURE_CODE = "fr-FR";
                const int ROOM_TYPE_ID = 1;
                const int BASE_RATE_PLAN_ID = 1;
                const int BUSINESS_ID = 1;
                const int PERIOD_ID = 1;
                const string ROOM_TYPE_NAME = "room Type";

                var baseRatePlanDao = MockRepository.GenerateMock<IBaseRatePlanDao>();
                var variantRatePlanDao = MockRepository.GenerateMock<IVariantRatePlanDao>();
                var ratePlanRateDao = MockRepository.GenerateMock<IBaseRatePlanRatesDao>();
                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var periodDao = MockRepository.GenerateMock<IPeriodDao>();


                baseRatePlanDao.Stub(r => r.GetByRoomTypeId(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new BaseRatePlan { Id = BASE_RATE_PLAN_ID, RackRate = 100 });
                periodDao.Stub(p => p.GetAllByBusiness(BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new List<Period>() { new Period() { Id = BUSINESS_ID, PeriodType = new PeriodType() { PeriodTypeEnum = PeriodTypeEnum.Season } } });

                roomTypeDao.Stub(r => r.GetByKey(ROOM_TYPE_ID)).Return(new RoomType { Name = ROOM_TYPE_NAME });
                ratePlanRateDao.Stub(rr => rr.GetByRatePlanId(BASE_RATE_PLAN_ID)).Return(
                        new List<RatePlanRate>
                        {
                            new RatePlanRate
                            {
                                MonMinStay = 1, 
                                MonRate = 100, 
                                TueMinStay = 1, 
                                TueRate = 100, 
                                WedMinStay = 1, 
                                WedRate = 100, 
                                ThuMinStay = 1, 
                                ThuRate = 100, 
                                FriMinStay = 1, 
                                FriRate = 100, 
                                SatMinStay = 1, 
                                SatRate = 100, 
                                SunMinStay = 1, 
                                SunRate = 100, 
                                RatePlanId = BASE_RATE_PLAN_ID, 
                                Period = new Period(), 
                                PeriodId = PERIOD_ID
                            }
                           
                        }
                 );

                var roomTypeManager = new RatePlanManager
                {
                    BaseRatePlanDao = baseRatePlanDao,
                    VariantRatePlanDao = variantRatePlanDao,
                    RatePlanRateDao = ratePlanRateDao,
                    RoomTypeDao = roomTypeDao,
                    PeriodDao = periodDao
                };


                variantRatePlanDao.Stub(r => r.GetByRoomTypeId(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new List<VariantRatePlan>{ new VariantRatePlan
                                {
                                    Name = "Low",
                                    ApplicableDays = "1111110",
                                    VariantAmount = 50,
                                    VariantType = new VariantType {Type = VariantTypeEnum.Amount}
                                }
                        }
                );

                //Act
                var variantRatePlans = roomTypeManager.GetVariantRatePlans(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE);

                Assert.IsNotNull(variantRatePlans);
                Assert.IsTrue(variantRatePlans.Count == 4, "Expect 2 actual and 2 evergreen rate plans");
                Assert.AreEqual((from rp in variantRatePlans
                                 from p in rp.Periods
                                    where p.Id == 0
                                select rp).Count(),2, "Expect 2 evergreen rate plans");
                Assert.AreEqual((from rp in variantRatePlans
                                 from p in rp.Periods
                                 where p.Id == 1
                                 select rp).Count(), 2, "Expect 2 actual rate plans");
            }
示例#12
0
            public void GetRatePlansByBusinessIdCallsCache()
            {
                // Arrange
                long businessId = 1;
                int ratePlanId = 1;
                string cultureCode = "en-GB";

                var ratePlan = new RatePlanView
                    {
                        RatePlanId = ratePlanId,
                        BusinessId = businessId,
                        RatePlanName = "RatePlan",
                        RoomTypeName = "RoomType",
                        IsActive = true
                    };

                CacheHelper.StubRatePlanViewCacheWithRatePlanViews(businessId, new List<RatePlanView> { ratePlan });
                // Invalidate the cache so it refreshes
                Business.Cache.Cache.RatePlanViewCache.Invalidate(businessId);

                var ratePlanManager = new RatePlanManager();

                // Act
                var result = ratePlanManager.GetRatePlanViewsByBusinessId(businessId, cultureCode);

                // Assert
                Assert.AreEqual(1, result.Count, "Number of rate plans returned was incorrect");
                
                CacheHelper.ReAssignRatePlanDaoToRatePlanViewCache();
            }
示例#13
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");
                }
            }
示例#14
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());
            }
示例#15
0
            public void GetBaseRatePlansWithExistingRoomTypeReturnCorrectRatePlanList()
            {
                //Arrange
                const string DEFAULT_CULTURE_CODE = "fr-FR";
                const int ROOM_TYPE_ID = 1;
                const int BASE_RATE_PLAN_ID = 1;
                const int BUSINESS_ID = 1;
                const int PERIOD_ID = 1;
                const string ROOM_TYPE_NAME = "room Type";

                var baseRatePlanDao = MockRepository.GenerateMock<IBaseRatePlanDao>();
                var variantRatePlanDao = MockRepository.GenerateMock<IVariantRatePlanDao>();
                var ratePlanRateDao = MockRepository.GenerateMock<IBaseRatePlanRatesDao>();
                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var periodDao = MockRepository.GenerateMock<IPeriodDao>();

                ////The Base rate plan
                baseRatePlanDao.Stub(r => r.GetByRoomTypeId(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new BaseRatePlan { Id = BASE_RATE_PLAN_ID, RackRate = 100 });

                periodDao.Stub(p => p.GetAllByBusiness(BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new List<Period>());

                roomTypeDao.Stub(r => r.GetByKey(ROOM_TYPE_ID)).Return(new RoomType {Name = ROOM_TYPE_NAME});

                //The base rate plan rates
                ratePlanRateDao.Stub(rr => rr.GetByRatePlanId(BASE_RATE_PLAN_ID)).Return(
                        new List<RatePlanRate>
                        {
                            new RatePlanRate
                            {
                                MonMinStay = 1, 
                                MonRate = 100, 
                                TueMinStay = 1, 
                                TueRate = 100, 
                                WedMinStay = 1, 
                                WedRate = 100, 
                                ThuMinStay = 1, 
                                ThuRate = 100, 
                                FriMinStay = 1, 
                                FriRate = 100, 
                                SatMinStay = 1, 
                                SatRate = 100, 
                                SunMinStay = 1, 
                                SunRate = 100, 
                                RatePlanId = BASE_RATE_PLAN_ID, 
                                Period = new Period(), 
                                PeriodId = PERIOD_ID
                            },
                            new RatePlanRate
                            {
                                MonMinStay = 1, 
                                MonRate = 100, 
                                TueMinStay = 1, 
                                TueRate = 100, 
                                WedMinStay = 1, 
                                WedRate = 100, 
                                ThuMinStay = 1, 
                                ThuRate = 100, 
                                FriMinStay = 1, 
                                FriRate = 100, 
                                SatMinStay = 1, 
                                SatRate = 100, 
                                SunMinStay = 1, 
                                SunRate = 100, 
                                RatePlanId = BASE_RATE_PLAN_ID, 
                                Period = new Period(), 
                                PeriodId = PERIOD_ID
                            },
                        }
                 );

                var roomTypeManager = new RatePlanManager
                                      {
                                          BaseRatePlanDao = baseRatePlanDao,
                                          VariantRatePlanDao = variantRatePlanDao, 
                                          RatePlanRateDao = ratePlanRateDao,
                                          RoomTypeDao = roomTypeDao
                                      };

                //Act
                var ratePlans = roomTypeManager.GetBaseRatePlans(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE);

                //Assert
                Assert.IsNotNull(ratePlans);
                Assert.IsTrue(ratePlans[0].Rates.MonRate.Value == 100);
                Assert.IsTrue(ratePlans[2].Rates.MonRate.Value == 100);

            }
示例#16
0
            public void DeleteVariantRatePlanIsSuccessful()
            {
                // Arrange
                const int RATE_PLAN_ID = 1;
                const long BUSINESS_ID = 1;

                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var variantRatePlanDao = new Mock<IVariantRatePlanDao>();
                var ratePlanManager = new RatePlanManager
                    {
                        EventTrackingManager = eventTrackingManager.Object,
                        VariantRatePlanDao = variantRatePlanDao.Object
                    };

                variantRatePlanDao.Setup(rp => rp.DeleteVariantRatePlan(RATE_PLAN_ID)).Returns(true);

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.VariantRatePlanDeleted, RATE_PLAN_ID.ToString(CultureInfo.InvariantCulture), null));

                // Act
                ratePlanManager.DeleteVariantRatePlan(RATE_PLAN_ID, BUSINESS_ID);

                // Assert
                variantRatePlanDao.VerifyAll();
                eventTrackingManager.VerifyAll();

            }
示例#17
0
            public void GetVariantRatePlansWithExistingRoomTypeReturnCorrectRatePlanList()
            {
                //Arrange
                const string DEFAULT_CULTURE_CODE = "fr-FR";
                const int ROOM_TYPE_ID = 1;
                const int BASE_RATE_PLAN_ID = 1;
                const int VARIANT_RATE_PLAN_ID = 1;
                const int BUSINESS_ID = 1;
                const int PERIOD_ID = 1;
                const string ROOM_TYPE_NAME = "room Type";

                var baseRatePlanDao = MockRepository.GenerateMock<IBaseRatePlanDao>();
                var variantRatePlanDao = MockRepository.GenerateMock<IVariantRatePlanDao>();
                var ratePlanRateDao = MockRepository.GenerateMock<IBaseRatePlanRatesDao>();
                var roomTypeDao = MockRepository.GenerateMock<IRoomTypeDao>();
                var periodDao = MockRepository.GenerateMock<IPeriodDao>();

                baseRatePlanDao.Stub(r => r.GetByRoomTypeId(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new BaseRatePlan { Id = BASE_RATE_PLAN_ID, RackRate = 100 });
                periodDao.Stub(p => p.GetAllByBusiness(BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new List<Period>());
                roomTypeDao.Stub(r => r.GetByKey(ROOM_TYPE_ID)).Return(new RoomType { Name = ROOM_TYPE_NAME });
                ratePlanRateDao.Stub(rr => rr.GetByRatePlanId(BASE_RATE_PLAN_ID)).Return(
                        new List<RatePlanRate>
                        {
                            new RatePlanRate
                            {
                                MonMinStay = 1, 
                                MonRate = 100, 
                                TueMinStay = 1, 
                                TueRate = 100, 
                                WedMinStay = 1, 
                                WedRate = 100, 
                                ThuMinStay = 1, 
                                ThuRate = 100, 
                                FriMinStay = 1, 
                                FriRate = 100, 
                                SatMinStay = 1, 
                                SatRate = 100, 
                                SunMinStay = 1, 
                                SunRate = 100, 
                                RatePlanId = BASE_RATE_PLAN_ID, 
                                Period = new Period(), 
                                PeriodId = PERIOD_ID
                            },
                            new RatePlanRate
                            {
                                MonMinStay = 1, 
                                MonRate = 100, 
                                TueMinStay = 1, 
                                TueRate = 100, 
                                WedMinStay = 1, 
                                WedRate = 100, 
                                ThuMinStay = 1, 
                                ThuRate = 100, 
                                FriMinStay = 1, 
                                FriRate = 100, 
                                SatMinStay = 1, 
                                SatRate = 100, 
                                SunMinStay = 1, 
                                SunRate = 100, 
                                RatePlanId = BASE_RATE_PLAN_ID, 
                                Period = new Period(), 
                                PeriodId = PERIOD_ID
                            },
                        }
                 );

                var roomTypeManager = new RatePlanManager
                {
                    BaseRatePlanDao = baseRatePlanDao,
                    VariantRatePlanDao = variantRatePlanDao,
                    RatePlanRateDao = ratePlanRateDao,
                    RoomTypeDao = roomTypeDao
                };

               
                variantRatePlanDao.Stub(r => r.GetByRoomTypeId(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE)).Return(new List<VariantRatePlan>{ new VariantRatePlan
                                {
                                    Name = "Low",
                                    ApplicableDays = "1111110",
                                    VariantAmount = 50,
                                    VariantType = new VariantType {Type = VariantTypeEnum.Amount},
                                    Id = BASE_RATE_PLAN_ID,
                                    VariantRatePlanRateId = VARIANT_RATE_PLAN_ID
                                }
                        }
                );

                //Act
                var variantRatePlans = roomTypeManager.GetVariantRatePlans(ROOM_TYPE_ID, BUSINESS_ID, DEFAULT_CULTURE_CODE);

                Assert.IsNotNull(variantRatePlans);
                Assert.IsTrue(variantRatePlans.Count == 2,"Expect one actual and one default variant plans");
                Assert.IsTrue(variantRatePlans[0].Rates.MonRate == 150);
                Assert.IsTrue(variantRatePlans[0].Rates.TueRate == 150);
                Assert.IsTrue(variantRatePlans[0].Rates.WedRate == 150);
                Assert.IsTrue(variantRatePlans[0].Rates.ThuRate == 150);
                Assert.IsTrue(variantRatePlans[0].Rates.FriRate == 150);
                Assert.IsTrue(variantRatePlans[0].Rates.SatRate == 150);
                Assert.IsTrue(variantRatePlans[0].Rates.SunRate == null);
            }
示例#18
0
            public void ModifyBaseRatePlanNoIdThrowsException()
            {
                // Arrange
                var ratePlanManager = new RatePlanManager();
                
                const int RATE_PLAN_ID = 1;
                const long BUSINESS_ID = 1;
                const int RATE_PLAN_RATE_ID = 5;

                var ratePlan = new BaseRatePlan { BusinessId = BUSINESS_ID, RatePlanType = new RatePlanType { Type = RatePlanTypeEnum.Base }, Rates = new RatePlanRate { Id = RATE_PLAN_RATE_ID } };

                try
                {
                    // Act
                    ratePlanManager.ModifyBaseRatePlan(ratePlan);

                    // Assert
                    Assert.Fail("Validation exception was not thrown");
                }
                catch (ValidationException vex)
                {
                    Assert.AreEqual(Errors.SRVEX30098.ToString(), vex.Code, "Incorrect validation exception was thrown");
                }
            }