public async Task Given_Validation_Result_When_GetStringAsync_Invoked_Then_It_Should_Return_Result(HttpStatusCode statusCode)
        {
            var requestUri = "http://localhost";
            var payload    = "{ \"hello\": \"world\" }";

            var validator = new Mock <ISchemaValidator>();

            validator.Setup(p => p.ValidateAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(true);

            var path = "default.json";

            using (var response = this._fixture.CreateHttpResponseMessage(statusCode, payload))
                using (var handler = this._fixture.CreateFakeHttpMessageHandler(response))
                    using (var httpClient = this._fixture.CreateHttpClient(handler))
                    {
                        var result = await HttpClientExtensions.GetStringAsync(httpClient, requestUri, validator.Object, path).ConfigureAwait(false);

                        result.Should().Be(payload);
                    }

            using (var response = this._fixture.CreateHttpResponseMessage(statusCode, payload))
                using (var handler = this._fixture.CreateFakeHttpMessageHandler(response))
                    using (var httpClient = this._fixture.CreateHttpClient(handler))
                    {
                        var result = await HttpClientExtensions.GetStringAsync(httpClient, new Uri(requestUri), validator.Object, path).ConfigureAwait(false);

                        result.Should().Be(payload);
                    }
        }
        public void Given_Validation_Error_When_GetStringAsync_Invoked_Then_It_Should_Throw_Exception(HttpStatusCode statusCode)
        {
            var requestUri = "http://localhost";
            var payload    = "{ \"hello\": \"world\" }";

            var exception = new SchemaValidationException();
            var validator = new Mock <ISchemaValidator>();

            validator.Setup(p => p.ValidateAsync(It.IsAny <string>(), It.IsAny <string>())).ThrowsAsync(exception);

            var path = "default.json";

            var func = default(Func <Task>);

            using (var handler = this._fixture.CreateFakeHttpMessageHandler(statusCode, payload))
                using (var httpClient = this._fixture.CreateHttpClient(handler))
                {
                    func = async() => await HttpClientExtensions.GetStringAsync(httpClient, requestUri, validator.Object, path).ConfigureAwait(false);

                    func.Should().Throw <SchemaValidationException>();
                }

            using (var handler = this._fixture.CreateFakeHttpMessageHandler(statusCode, payload))
                using (var httpClient = this._fixture.CreateHttpClient(handler))
                {
                    func = async() => await HttpClientExtensions.GetStringAsync(httpClient, new Uri(requestUri), validator.Object, path).ConfigureAwait(false);

                    func.Should().Throw <SchemaValidationException>();
                }
        }
        public void Given_Null_Parameters_When_GetStringAsync_Invoked_Then_It_Should_Throw_Exception()
        {
            var requestUri = "http://localhost";
            var validator  = new Mock <ISchemaValidator>();

            var func = default(Func <Task>);

            using (var httpClient = this._fixture.CreateHttpClient())
            {
                func = async() => await HttpClientExtensions.GetStringAsync(null, (string)null, null, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(httpClient, (string)null, null, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(httpClient, requestUri, null, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(httpClient, requestUri, validator.Object, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(null, (Uri)null, null, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(httpClient, (Uri)null, null, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(httpClient, new Uri(requestUri), null, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();

                func = async() => await HttpClientExtensions.GetStringAsync(httpClient, new Uri(requestUri), validator.Object, null).ConfigureAwait(false);

                func.Should().Throw <ArgumentNullException>();
            }
        }
        public void Given_Error_Response_When_GetStringAsync_Invoked_Then_It_Should_Throw_Exception(HttpStatusCode statusCode)
        {
            var requestUri = "http://localhost";
            var validator  = new Mock <ISchemaValidator>();
            var path       = "default.json";

            var func = default(Func <Task>);

            using (var handler = this._fixture.CreateFakeHttpMessageHandler(statusCode))
                using (var httpClient = this._fixture.CreateHttpClient(handler))
                {
                    func = async() => await HttpClientExtensions.GetStringAsync(httpClient, requestUri, validator.Object, path).ConfigureAwait(false);

                    func.Should().Throw <HttpRequestException>();
                }

            using (var handler = this._fixture.CreateFakeHttpMessageHandler(statusCode))
                using (var httpClient = this._fixture.CreateHttpClient(handler))
                {
                    func = async() => await HttpClientExtensions.GetStringAsync(httpClient, new Uri(requestUri), validator.Object, path).ConfigureAwait(false);

                    func.Should().Throw <HttpRequestException>();
                }
        }