public async Task HttpTesterClientAddGetHttpRequest_Success() { var urlSource = new SwaggerUrlSource(options => { options.AddBaseUrl(new Uri("https://qatoolkitapi.azurewebsites.net/")); options.AddRequestFilters(new RequestFilter() { EndpointNameWhitelist = new string[] { "GetAllBikes" } }); options.UseSwaggerExampleValues = true; }); var requests = await urlSource.Load(new Uri[] { new Uri("https://qatoolkitapi.azurewebsites.net/swagger/v2/swagger.json") }); using (var client = new HttpTesterClient()) { var response = await client .CreateHttpRequest(requests.FirstOrDefault()) .Start(); var msg = await response.GetResponseJsonBody <List <Bicycle> >(); var expectedResponse = BicycleFixture.GetBicycles().ToExpectedObject(); expectedResponse.ShouldEqual(msg); Assert.True(client.Duration < 2000); Assert.True(response.IsSuccessStatusCode); } }
public async Task HttpTesterClientSimple_Success() { using (var client = new HttpTesterClient()) { var response = await client .CreateHttpRequest(new Uri("https://qatoolkitapi.azurewebsites.net")) .WithQueryParams(new Dictionary <string, string>() { { "api-version", "1" } }) .WithMethod(HttpMethod.Get) .WithPath("/api/bicycles") .Start(); var msg = await response.GetResponseJsonBody <List <Bicycle> >(); var expectedResponse = BicycleFixture.GetBicycles().ToExpectedObject(); expectedResponse.ShouldEqual(msg); Assert.True(client.Duration < 2000); Assert.True(response.IsSuccessStatusCode); } }