public BaseRatePlanDto CreateBaseRatePlan(BaseRatePlanDto ratePlanDto)
        {
            if (ratePlanDto == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30088, "PropertyManagementSystemService.CreateBaseRatePlan"));
            }

            var ratePlanToCreate = Mapper.Map<BaseRatePlanDto, BaseRatePlan>(ratePlanDto);

            var ratePlanCreated = ratePlanManager.CreateBaseRatePlan(ratePlanToCreate);

            return Mapper.Map<BaseRatePlan, BaseRatePlanDto>(ratePlanCreated);
        }
            public void ModifyRoomTypeAndBaseRatePlanIsSuccessful()
            {
                // Arrange
                var roomTypeManager = MockRepository.GenerateMock<IRoomTypeManager>();
                PropertyManagementSystemService.RoomTypeManager = roomTypeManager;

                var ratePlan = new BaseRatePlanDto
                {
                    RoomTypeId = 1,
                    MaxOccupancy = 4,
                    MaxAdults = 2,
                    MaxChildren = 2,
                    BoardBasis = new BoardBasisDto { Code = "BK" },
                    CancellationClass = new CancellationClassDto { Code = "FR" }
                };

                var roomType = new RoomTypeDto
                {
                    BusinessId = BUSINESS_ID,
                    RoomClass = new RoomClassDto { Code = "DBL" },
                    QualityType = new QualityTypeDto { Code = "CTG" },
                    BathroomType = new BathroomTypeDto { Code = "PB" },
                    Aspect = new AspectDto { Code = "CVW" },
                    RatePlans = new List<BaseRatePlanDto>
                        {
                            ratePlan
                        }
                };

                roomTypeManager.Expect(r => r.ModifyRoomTypeAndBaseRatePlan(Arg<RoomType>.Is.Anything));

                // Act
                PropertyManagementSystemService.ModifyRoomTypeAndBaseRatePlan(roomType);

                // Assert
                roomTypeManager.VerifyAllExpectations();
            }
            public void ModifyBaseRatePlanIsSuccessful()
            {
                // Arrange
                var ratePlanManagerStub = MockRepository.GenerateMock<IRatePlanManager>();
                PropertyManagementSystemService.RatePlanManager = ratePlanManagerStub;

                var ratePlan = new BaseRatePlanDto()
                {
                    BusinessId = 1,
                    BoardBasis = new BoardBasisDto { Code = BoardBasisTypeEnum.FullBoard.GetCode() },
                    CancellationClass = new CancellationClassDto { Code = CancellationClassTypeEnum.FullyRefundable.GetCode() }
                };

                ratePlanManagerStub.Expect(x => x.ModifyBaseRatePlan(Arg<BaseRatePlan>.Is.Anything)).Return(new BaseRatePlan());

                // Act
                var returnedRatePlan = PropertyManagementSystemService.ModifyBaseRatePlan(ratePlan);

                // Assert
                Assert.IsNotNull(returnedRatePlan, "The modify of the rate plans 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 BaseRatePlanDto ModifyBaseRatePlan(BaseRatePlanDto ratePlanDto)
        {
            if (ratePlanDto == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30088, "PropertyManagementSystemService.ModifyBaseRatePlan"));
            }

            CheckAccessRights(ratePlanDto.BusinessId);

            var ratePlanToModify = Mapper.Map<BaseRatePlanDto, BaseRatePlan>(ratePlanDto);

            var ratePlanModified = ratePlanManager.ModifyBaseRatePlan(ratePlanToModify);

            return Mapper.Map<BaseRatePlan, BaseRatePlanDto>(ratePlanModified);
        }
示例#6
0
文件: PMSTest.cs 项目: ognjenm/egle
            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");
            }