Esempio n. 1
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);
            }
Esempio n. 2
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");
            }