Beispiel #1
0
        public void CheckAvailability_ValidSearchRequestAndResultIsReturnedWithTwoHotels_NewPriceShouldBeBiggerThanPrice()
        {
            //Arrange

            _hotelAvailability.Setup(x => x.SearchHotelAvailability(It.IsAny <HotelAvailabilityRequest>())).Returns(_hotelFixtureData.MockedHotelAvailabilityResponse);
            _pricingService.SetupSequence(x => x.CalculatePrice(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>()))
            .Returns(120)
            .Returns(170);
            //TODO: Check this
            //_pricingService.SetupSequence(x =>
            //            x.CalculatePrice(_hotelFixtureData.MockedHotelAvailabilityResponse.CheckIn,
            //                             _hotelFixtureData.MockedHotelAvailabilityResponse.CheckOut,
            //                             100))
            //    .Returns(120)
            //    .Returns(170);

            //Act
            var availabilityService = new AvailabilityService(_hotelRepository.Object, _hotelAvailability.Object, _pricingService.Object);
            var result = availabilityService.CheckAvailability(_searchFixtureData.ValidRequestCase1, It.IsAny <List <string> >());

            //Assert
            foreach (var item in result.AvailableHotels)
            {
                foreach (var room in item.AvailableRooms)
                {
                    //Assert.True(room.NewPrice > room.Price);
                    room.NewPrice.Should().BeGreaterThan(room.Price);
                }
            }
        }
        public void CheckAvailability_ValidSearchRequestAndTheServiceReturnedTwoHotels_ResultShouldContainTwoHotels()
        {
            _mockedHotelAvailability.Setup(x => x.SearchHotelAvailability(It.IsAny <HotelAvailabilityRequest>())).Returns(_searchServiceFixtureData.MockedHotelAvailabilityResponse);
            int expCount = 2;

            var availabilityService = new AvailabilityService(_mockedHotelRepository.Object, _mockedHotelAvailability.Object, _mockedPricingService.Object);
            var result = availabilityService.CheckAvailability(_searchFixtureData.ValidRequestCase1, It.IsAny <List <string> >());

            Assert.Equal(expCount, result.Count);
        }
Beispiel #3
0
        public void CheckAvailability_ValidSearchRequestAndResultIsReturnedWithTwoHotels_ResultShouldContainTwoHotels()
        {
            //Arrange
            _hotelAvailability.Setup(x => x.SearchHotelAvailability(It.IsAny <HotelAvailabilityRequest>())).Returns(_hotelFixtureData.MockedHotelAvailabilityResponse);
            int expectedHotelsCount = 2;

            //Act
            var availabilityService = new AvailabilityService(_hotelRepository.Object, _hotelAvailability.Object, _pricingService.Object);
            var result = availabilityService.CheckAvailability(_searchFixtureData.ValidRequestCase1, It.IsAny <List <string> >());

            //Assert
            Assert.Equal(expectedHotelsCount, result.AvailableHotels.Count);
        }
        public void CheckAvailability_ValidSearchRequestAndTheServiceReturnedTwoHotels_TheNewPriceShouldHaveValue()
        {
            _mockedHotelAvailability.Setup(x => x.SearchHotelAvailability(It.IsAny <HotelAvailabilityRequest>())).Returns(_searchServiceFixtureData.MockedHotelAvailabilityResponse);
            _mockedPricingService.Setup(x => x.CalculatePrice(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>())).Returns(150);

            var availabilityService = new AvailabilityService(_mockedHotelRepository.Object, _mockedHotelAvailability.Object, _mockedPricingService.Object);
            var result = availabilityService.CheckAvailability(_searchFixtureData.ValidRequestCase1, It.IsAny <List <string> >());

            foreach (var item in result.AvailableHotels)
            {
                item.AvailableRooms.Select(x => x.NewPrice).Should().NotContainNulls();
                //foreach (var room in item.AvailableRooms)
                //{
                //    Assert.True(room.NewPrice > 0);
                //}
            }
        }
        public void CheckAvailability_ValidSearchRequestAndTheServiceReturnedTwoHotelsWithSetupSequence_TheNewPriceShouldBeBiggerThanPrice()
        {
            _mockedHotelAvailability.Setup(x => x.SearchHotelAvailability(It.IsAny <HotelAvailabilityRequest>())).Returns(_searchServiceFixtureData.MockedHotelAvailabilityResponse);
            _mockedPricingService.SetupSequence(x => x.CalculatePrice(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>()))
            .Returns(120)
            .Returns(180);

            var availabilityService = new AvailabilityService(_mockedHotelRepository.Object, _mockedHotelAvailability.Object, _mockedPricingService.Object);
            var result = availabilityService.CheckAvailability(_searchFixtureData.ValidRequestCase1, It.IsAny <List <string> >());

            foreach (var item in result.AvailableHotels)
            {
                //item.AvailableRooms.Select(x => x.NewPrice).Should().HaveCountGreaterThan();
                foreach (var room in item.AvailableRooms)
                {
                    Assert.True(room.NewPrice > room.Price);
                }
            }
        }