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