public async Task ExternalHistoricServiceDetailsDown_ReturnsServiceUnavailable() { var mockHttp = new MockHttpMessageHandler(); mockHttp.When(serviceMetricsUri) .Respond("application/json", JsonConvert.SerializeObject(HistoricalServiceMockData.GetServiceMetricsResponse())); var serviceDetailsRequest = mockHttp.When(serviceDetailsUri) .Respond(HttpStatusCode.InternalServerError); var client = GetTestClientwithExternalclientMocked(mockHttp.ToHttpClient()); var response = await client.GetAsync("/HistoricalData?startLocation=CFL&EndLocation=LDS&startDate=2021/03/25 07:00&endDate=2021/03/25 07:30"); Assert.Equal(503, (int)response.StatusCode); Assert.Equal(1, mockHttp.GetMatchCount(serviceDetailsRequest)); }
public async Task ExternalHistoricServiceWorking_ExpectedDataReturned() { var mockHttp = new MockHttpMessageHandler(); mockHttp.When(serviceMetricsUri) .Respond("application/json", JsonConvert.SerializeObject(HistoricalServiceMockData.GetServiceMetricsResponse())); mockHttp.When(serviceDetailsUri) .Respond("application/json", JsonConvert.SerializeObject(HistoricalServiceMockData.GetServiceDetailsResponse())); var client = GetTestClientwithExternalclientMocked(mockHttp.ToHttpClient()); var response = await client.GetAsync("/HistoricalData?startLocation=CFL&EndLocation=LDS&startDate=2021/03/25 07:00&endDate=2021/03/25 07:30"); response.EnsureSuccessStatusCode(); var content = await response.Content.ReadAsStringAsync(); var actualResponse = JsonConvert.DeserializeObject <IList <HistoricalRecord> >(content); actualResponse.ShouldDeepEqual(HistoricalServiceMockData.GetExpectedApiResponse()); }