Skip to content

Commit

Permalink
test got a bit too convoluted for my tastes, this is good enough
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd committed Oct 20, 2023
1 parent c25e835 commit b513532
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions test/Flurl.Test/Http/FlurlClientBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,15 @@ public async Task can_add_middleware() {

[Test]
public void inner_hanlder_is_SocketsHttpHandler_when_supported() {
var shh = typeof(HttpClientHandler).Assembly.DefinedTypes.FirstOrDefault(t => t.Name == "SocketsHttpHandler");
var supported = (shh != null);
#if NET
Assert.IsTrue(supported, "SocketsHttpHandler should be defined"); // sanity check (tests the test, basically)
#endif
if (supported) {
Console.WriteLine($"{shh.FullName} Found in {typeof(HttpClientHandler).Assembly.FullName}");
supported = shh.GetProperty("IsSupported")?.GetValue(Activator.CreateInstance(shh)) as bool? == true;
Console.WriteLine($"IsSupported = {supported}");
}

HttpMessageHandler handler = null;
new FlurlClientBuilder()
.ConfigureInnerHandler(h => handler = h)
.Build();

var expected = supported ? "SocketsHttpHandler" : "HttpClientHandler";
Assert.AreEqual(expected, handler?.GetType().Name);
#if NET
Assert.IsInstanceOf<SocketsHttpHandler>(handler);
#else
Assert.IsInstanceOf<HttpClientHandler>(handler);
#endif
}

class BlockingHandler : DelegatingHandler
Expand Down

0 comments on commit b513532

Please sign in to comment.