示例#1
0
        public void Then_If_It_Is_Not_Successful_An_Exception_Is_Thrown()
        {
            //Arrange
            var response = new HttpResponseMessage
            {
                Content    = new StringContent(""),
                StatusCode = HttpStatusCode.BadRequest
            };
            var httpMessageHandler = MessageHandler.SetupMessageHandlerMock(response, new Uri(string.Format(Constants.NationalOfficeOfStatisticsLocationUrl, 2000, 0)));
            var client             = new HttpClient(httpMessageHandler.Object);
            var locationService    = new NationalStatisticsLocationService(client);

            //Act Assert
            Assert.ThrowsAsync <HttpRequestException>(() => locationService.GetLocations());
        }
示例#2
0
        public async Task Then_The_Endpoint_Is_Called_And_Location_Data_Returned(
            OnsLocationApiResponse importLocations)
        {
            //Arrange
            importLocations.ExceededTransferLimit = false;
            var response = new HttpResponseMessage
            {
                Content    = new StringContent(JsonConvert.SerializeObject(importLocations)),
                StatusCode = HttpStatusCode.Accepted
            };
            var httpMessageHandler = MessageHandler.SetupMessageHandlerMock(response, new Uri(string.Format(Constants.NationalOfficeOfStatisticsLocationUrl, 2000, 0)));
            var client             = new HttpClient(httpMessageHandler.Object);
            var locationService    = new NationalStatisticsLocationService(client);

            //Act
            var actual = await locationService.GetLocations();

            //Assert
            actual.Should().BeEquivalentTo(importLocations.Features);
        }