public async Task HttpTesterClientAddPostHttpRequest_Success()
        {
            var urlSource = new SwaggerUrlSource(options =>
            {
                options.AddBaseUrl(new Uri("https://qatoolkitapi.azurewebsites.net/"));
                options.AddRequestFilters(new RequestFilter()
                {
                    EndpointNameWhitelist = new string[] { "NewBike" }
                });
                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())
                               .WithJsonBody(BicycleFixture.Get())
                               .Start();

                var msg = await response.GetResponseJsonBody <Bicycle>();

                Assert.True(client.Duration < 2000);
                Assert.True(response.IsSuccessStatusCode);
                Assert.Equal("Giant", msg.Brand);
            }
        }
        public async Task HttpTesterClientWithSwagger_Success()
        {
            var urlSource = new SwaggerUrlSource(options =>
            {
                options.AddBaseUrl(new Uri("https://qatoolkitapi.azurewebsites.net/"));
                options.AddRequestFilters(new RequestFilter()
                {
                    EndpointNameWhitelist = new string[] { "NewBike" }
                });
                options.UseSwaggerExampleValues = true;
            });

            var requests = await urlSource.Load(new Uri[]
            {
                new Uri("https://qatoolkitapi.azurewebsites.net/swagger/v1/swagger.json")
            });

            var replacementValues = new Dictionary <string, object>
            {
                { "api-version", 1 }
            };

            var urlGenerator = new HttpRequestUrlGenerator(requests.FirstOrDefault(),
                                                           options => { options.AddReplacementValues(replacementValues); });

            using (var client = new HttpTesterClient())
            {
                var response = await client
                               .CreateHttpRequest(new Uri(urlGenerator.GetUrl()))
                               .WithHeaders(new Dictionary <string, string>()
                {
                    { "Content-Type", "application/json" }
                })
                               .WithMethod(HttpMethod.Post)
                               .WithJsonBody(BicycleFixture.Get())
                               .Start();

                var msg = await response.GetResponseJsonBody <Bicycle>();

                Assert.True(client.Duration < 2000);
                Assert.True(response.IsSuccessStatusCode);
                Assert.Equal("Giant", msg.Brand);
            }
        }
        public async Task HttpTesterClientWithoutMethod_Exception()
        {
            using (var client = new HttpTesterClient())
            {
                var response = client
                               .CreateHttpRequest(new Uri("https://qatoolkitapi.azurewebsites.net"))
                               .WithHeaders(new Dictionary <string, string>()
                {
                    { "Content-Type", "application/json" }
                })
                               .WithQueryParams(new Dictionary <string, string>()
                {
                    { "api-version", "1" }
                })
                               .WithJsonBody(BicycleFixture.Get());

                await Assert.ThrowsAsync <QAToolKitEngineHttpTesterException>(async() => await client.Start());
            }
        }
        public async Task HttpTesterClientWithoutQueryParams_Success()
        {
            using (var client = new HttpTesterClient())
            {
                var response = await client
                               .CreateHttpRequest(new Uri("https://qatoolkitapi.azurewebsites.net"))
                               .WithHeaders(new Dictionary <string, string>()
                {
                    { "Content-Type", "application/json" }
                })
                               .WithMethod(HttpMethod.Post)
                               .WithJsonBody(BicycleFixture.Get())
                               .WithPath("/api/bicycles")
                               .Start();

                Assert.True(client.Duration < 2000);
                Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
            }
        }