public static BSHotelAvailability GetPerfect(AvailabilityRateType rateType, int nights)
        {
            var av = new BSHotelAvailability {
                Name = EmulateDtosAndModelsValues.HOTEL_NAME
            };

            av.AddRate(EmulateDtosAndModelsValues.RATE_NAME_1, GetPrice(rateType, nights));
            return(av);
        }
        public static BSHotelAvailability GeValidWithBadBoardPrice(int nights)
        {
            var av = new BSHotelAvailability {
                Name = EmulateDtosAndModelsValues.HOTEL_NAME
            };

            av.AddRate(EmulateDtosAndModelsValues.RATE_NAME_2, GetPrice(AvailabilityRateType.Stay, nights));
            return(av);
        }
示例#3
0
        public void AddRate_NewRateAdded_FirstRateFromNullToNotNull()
        {
            var availability = new BSHotelAvailability();

            Assert.IsNull(availability.Rates.FirstOrDefault());

            string  boardName  = "Board Type";
            decimal finalPrice = 35;

            availability.AddRate(boardName, finalPrice);

            Assert.IsNotNull(availability.Rates.FirstOrDefault());
            Assert.IsTrue(availability.Rates.First().BoardType == boardName);
            Assert.IsTrue(availability.Rates.First().FinalPrice == finalPrice);
        }
        public BSHotelAvailability Translate(BSAvailabilityDto dto, int nights)
        {
            if (!_validator.IsAcceptedResponse(dto))
            {
                return(null);
            }

            var bsHotel = new BSHotelAvailability {
                Name = dto.hotel.name
            };

            foreach (var rate in dto.rates)
            {
                if (_validator.IsCorrectRate(rate))
                {
                    bsHotel.AddRate(
                        boardType: rate.boardType,
                        finalPrice: GetRateFinalPrice(rate, nights)
                        );
                }
            }

            return(bsHotel);
        }