public void Request_SearchRequestIsValid_TheReturnedResultShouldBeOfTypeHotelAvailabilityRequest()
        {
            var availabilityService = new AvailabilityService(_mockedHotelRepository.Object, _mockedHotelAvailability.Object, _mockedPricingService.Object);
            var result = availabilityService.Request(_searchFixtureData.ValidRequestCase1);

            Assert.IsType <HotelAvailabilityRequest>(result);
        }
Пример #2
0
        public async Task AvailabilityService_Request_RequestExecuted()
        {
            var mockFactory = new Mock <IHttpClientFactory>();

            var mockHttpMessageHandler = new Mock <HttpMessageHandler>();

            mockHttpMessageHandler.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{'health':'Ok'}")
            });

            var client = new HttpClient(mockHttpMessageHandler.Object);

            mockFactory.Setup(_ => _.CreateClient(It.IsAny <string>())).Returns(client);

            var availabilityService = new AvailabilityService(mockFactory.Object);

            var response = await availabilityService.Request("http://google.com/", CancellationToken.None)
                           .ConfigureAwait(false);

            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal("{'health':'Ok'}", response.Body);
        }
Пример #3
0
        public void Request_SearchRequestIsValid_ResultShouldBeOfTypeHotelAvailabilityRequest()
        {
            //Arrange

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

            //Assert
            Assert.IsType <HotelAvailabilityRequest>(result);
        }
        public void Request_SearchRequestIsValid_ShouldHaveCorrectData()
        {
            var availabilityService = new AvailabilityService(_mockedHotelRepository.Object, _mockedHotelAvailability.Object, _mockedPricingService.Object);
            var result = availabilityService.Request(_searchFixtureData.ValidRequestCase1);

            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.CheckIn, result.CheckIn);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.CheckOut, result.CheckOut);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Nights, result.Nights);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Adults, result.Adults);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Children, result.Children);
        }
Пример #5
0
        public void Request_SearchRequestIsValid_ShouldContainCorrectData()
        {
            //Arrange

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

            //Assert
            //Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.CheckIn, result.CheckIn);
            //Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.CheckOut, result.CheckOut);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Nights, result.Nights);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Adults, result.Adults);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Children, result.Children);
            Assert.Equal(_searchFixtureData.HotelAvailabilityRequestCase1.Rooms, result.Rooms);
        }