Beispiel #1
0
            public void CreateRatePlanSuccess()
            {
                // Arrange
                var pms = new PropertyManagementSystemService {DisableAccessRightsCheck = true};

                const long BUSINESS_ID = 1;
                var periodDto = new PeriodDto 
                {
                    BusinessId = BUSINESS_ID, 
                    Name = "High", 
                    PeriodDateRanges = new List<PeriodDateRangeDto>
                    {
                        new PeriodDateRangeDto { StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1)}
                    }
                };
                PeriodDto period = pms.CreateSeason(BUSINESS_ID, periodDto, "en-GB");

                var rates = new RatePlanRateDto
                                {
                                    BusinessId = BUSINESS_ID,
                                    PeriodId = period.Id.Value,
                                    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 ratePlanDto = new BaseRatePlanDto
                {
                    BusinessId = BUSINESS_ID,
                    RoomTypeId = 1,
                    MaxAdults = 2,
                    MaxChildren = 1,
                    MaxOccupancy = 3,
                    CancellationClass = new CancellationClassDto { Code = "FR"},
                    BoardBasis = new BoardBasisDto { Code = "BK" },
                    Rates = rates,
                    RatePlanType = new RatePlanTypeDto { Type = RatePlanTypeEnumDto.Base},
                    CurrencyCode = "GBP"
                };

                // Act
                BaseRatePlanDto result = pms.CreateBaseRatePlan(ratePlanDto);

                // Assert
                Assert.IsNotNull(result, "RatePlan hasn't been created");
                Assert.IsNotNull(result.Rates, "Rates were not created");
                Assert.IsTrue(result.Rates.Id != default(int), "Rate id was not populated");
            }
            public void CreateBaseRatePlanRateIsSuccessful()
            {
                // Arrange
                var ratePlanManagerStub = MockRepository.GenerateStub<IRatePlanManager>();
                PropertyManagementSystemService.RatePlanManager = ratePlanManagerStub;

                const int RATE_PLAN_ID = 1;
                var ratePlanRate = new RatePlanRateDto
                                   {
                                       BusinessId = BUSINESS_ID,
                                       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)
                                    };

                ratePlanManagerStub.Expect(x => x.CreateRatePlanRate(Arg<RatePlanRate>.Is.Anything, Arg<bool>.Is.Anything)).Return(Mapper.Map<RatePlanRateDto, RatePlanRate>(ratePlanRate));

                // Act
                var returnedRatePlanRate = PropertyManagementSystemService.CreateBaseRatePlanRates(ratePlanRate);

                // Assert
                Assert.IsNotNull(returnedRatePlanRate, "The creation of the rate plans rates failed");
            }
            public void ModifyRatePlanRatesIsSuccessful()
            {
                // Arrange
                const int RATE_PLAN_ID = 1;
                var ratePlanManagerStub = MockRepository.GenerateMock<IRatePlanManager>();
                PropertyManagementSystemService.RatePlanManager = ratePlanManagerStub;

                var ratePlanRate = new RatePlanRateDto
                {
                    BusinessId = BUSINESS_ID,
                    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)
                };

                ratePlanManagerStub.Expect(x => x.ModifyRatePlanRates(Arg<RatePlanRate>.Is.Anything, Arg<bool>.Is.Anything)).Return(new RatePlanRate());

                // Act
                var returnedRatePlan = PropertyManagementSystemService.ModifyRatePlanRates(ratePlanRate);

                // Assert
                Assert.IsNotNull(returnedRatePlan, "The modify of the rate plan rates failed");
                ratePlanManagerStub.VerifyAllExpectations();
            }
            public void CreateBaseRatePlanIsSuccessful()
            {
                // Arrange
                var ratePlanManagerStub = MockRepository.GenerateStub<IRatePlanManager>();
                PropertyManagementSystemService.RatePlanManager = ratePlanManagerStub;

                const int RATE_PLAN_ID = 1;
                var rates = new RatePlanRateDto
                            {
                                BusinessId = BUSINESS_ID,
                                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 BaseRatePlanDto
                {
                    Rates = rates,
                    BoardBasis = new BoardBasisDto { Code = "BK" },
                    CancellationClass = new CancellationClassDto { Code = "FR" },
                    RatePlanType = new RatePlanTypeDto { Type = RatePlanTypeEnumDto.Base, Name = "BAS" },
                };

                ratePlanManagerStub.Expect(x => x.CreateBaseRatePlan(Arg<BaseRatePlan>.Is.Anything)).Return(Mapper.Map<BaseRatePlanDto, BaseRatePlan>(ratePlan));
                
                // Act
                BaseRatePlanDto returnedRatePlan = PropertyManagementSystemService.CreateBaseRatePlan(ratePlan);

                // Assert
                Assert.IsNotNull(returnedRatePlan, "The creation of the rate plans failed");
                Assert.IsNotNull(returnedRatePlan.Rates, "The creation of the rate plans failed");
            }
        public RatePlanRateDto CreateBaseRatePlanRates(RatePlanRateDto ratePlanDto)
        {
            if (ratePlanDto == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30088, "PropertyManagementSystemService.CreateBaseRatePlanRates"));
            }

            var ratePlanRateToCreate = Mapper.Map<RatePlanRateDto, RatePlanRate>(ratePlanDto);

            var ratePlanRateCreated = ratePlanManager.CreateRatePlanRate(ratePlanRateToCreate);

            return Mapper.Map<RatePlanRate, RatePlanRateDto>(ratePlanRateCreated);
        }
        public RatePlanRateDto ModifyRatePlanRates(RatePlanRateDto ratePlanRatesDto)
        {
            if (ratePlanRatesDto == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30088, "PropertyManagementSystemService.ModifyRatePlanRates"));
            }

            CheckAccessRights(ratePlanRatesDto.BusinessId);

            var ratePlanRateToModify = Mapper.Map<RatePlanRateDto, RatePlanRate>(ratePlanRatesDto);

            var ratePlanRateModified = ratePlanManager.ModifyRatePlanRates(ratePlanRateToModify);

            return Mapper.Map<RatePlanRate, RatePlanRateDto>(ratePlanRateModified);
        }