From 738661cdea2532887cb631a482c3d2f4bef53175 Mon Sep 17 00:00:00 2001 From: Sunghwan Bang Date: Sat, 28 Oct 2023 12:28:49 +0900 Subject: [PATCH] tests --- .../GraphQLHttpClientConfigurationTests.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs diff --git a/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs new file mode 100644 index 00000000000..a12cd23f40a --- /dev/null +++ b/src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs @@ -0,0 +1,35 @@ +using System.Net; +using static HotChocolate.AspNetCore.Tests.Utilities.TestServerExtensions; + +namespace HotChocolate.Transport.Http.Tests; + +public class GraphQLHttpClientConfigurationTests +{ + [Fact] + public async Task DefaultRequestVersion() + { + var httpClient = new HttpClient(new TestHttpMessageHandler( + request => + { + Assert.Equal(HttpVersion.Version20, request.Version); + Assert.Equal(HttpVersionPolicy.RequestVersionOrHigher, request.VersionPolicy); + return new(); + } + )) + { + DefaultRequestVersion = HttpVersion.Version20, + DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher, + }; + + var client = GraphQLHttpClient.Create(httpClient, true); + await client.SendAsync(new("{ __typename }", new(CreateUrl(default))), default); + } + + class TestHttpMessageHandler(Func sender) : HttpMessageHandler + { + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + return Task.FromResult(sender.Invoke(request)); + } + } +}