Skip to content

Commit

Permalink
Breaking change: IRestClient.InvokeAsync() now accepts a factory of H…
Browse files Browse the repository at this point in the history
…ttpContent, which allows to work-around an issue with certain versions of .NET Standard and .NET Framework (dotnet/runtime#14612)

Fixed an issue which prevented MultiplexedRestClient to properly retry HTTP invocations on failures
Fixed an issue with IAsyncEnumerable support on .NET Core 3.1 (was mistakenly disabled in previous releases)
Improved the way we throw `OperationCanceledException`s in several code paths
Improved unit tests
  • Loading branch information
verifalia committed Jan 22, 2021
1 parent 6db320f commit 8d693f0
Show file tree
Hide file tree
Showing 87 changed files with 199 additions and 137 deletions.
2 changes: 1 addition & 1 deletion source/Verifalia.Api.Tests/DummyRestClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
38 changes: 32 additions & 6 deletions source/Verifalia.Api.Tests/MultiplexedRestClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down Expand Up @@ -32,6 +32,7 @@
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http.Testing;
using Verifalia.Api.Exceptions;
Expand Down Expand Up @@ -60,7 +61,22 @@ public async Task ShouldThrowServiceUnreachableExceptionWhenAllEndpointsReturnSe
}

[Fact]
public async Task ShouldThrowServiceUnreachableExceptionWhenAllEndpointsTimeOut()
public async Task ShouldThrowServiceUnreachableExceptionWhenAllEndpointsFail()
{
using (var httpTest = new HttpTest())
{
// Two subsequent calls should result in a server error 5xx

httpTest.RespondWith("Internal server error", 500);
httpTest.RespondWith("Internal server error", 500);

var client = new MultiplexedRestClient(_authenticator, "dummy", new[] { new Uri("https://dummy1"), new Uri("https://dummy2") });
await Assert.ThrowsAsync<ServiceUnreachableException>(async () => await client.InvokeAsync(HttpMethod.Get, "dummy"));
}
}

[Fact]
public async Task ShouldThrowServiceUnreachableExceptionWhenAllEndpointsTimeout()
{
using (var httpTest = new HttpTest())
{
Expand All @@ -75,7 +91,18 @@ public async Task ShouldThrowServiceUnreachableExceptionWhenAllEndpointsTimeOut(
}

[Fact]
public async Task ShouldSucceedWhenAtLeastOneEndpointDoesNotReturnServerError()
public async Task ShouldThrowOperationCanceledExceptionWhenCanceledWithCancellationToken()
{
using (var httpTest = new HttpTest())
{
var ct = new CancellationToken(true);
var client = new MultiplexedRestClient(_authenticator, "dummy", new[] { new Uri("https://dummy1"), new Uri("https://dummy2") });
await Assert.ThrowsAsync<OperationCanceledException>(async () => await client.InvokeAsync(HttpMethod.Get, "dummy", cancellationToken: ct));
}
}

[Fact]
public async Task ShouldSucceedWhenAtLeastOneEndpointDoesNotFail()
{
using (var httpTest = new HttpTest())
{
Expand All @@ -91,7 +118,7 @@ public async Task ShouldSucceedWhenAtLeastOneEndpointDoesNotReturnServerError()
}

[Fact]
public async Task ShouldSucceedWhenAtLeastOneEndpointDoesNotTimeOut()
public async Task ShouldSucceedWhenAtLeastOneEndpointDoesNotTimeout()
{
using (var httpTest = new HttpTest())
{
Expand All @@ -105,8 +132,7 @@ public async Task ShouldSucceedWhenAtLeastOneEndpointDoesNotTimeOut()
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}



[Fact]
public async Task ShouldImmediatelyFailOnForbiddenError()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
4 changes: 2 additions & 2 deletions source/Verifalia.Api.Tests/ValidationRestClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task ShouldHandleQueryOfInProgressJobs()
overview = new
{
id = validationId,
status = "in-progress"
status = "InProgress"
}
}, 202);

Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/BaseUrisProviders/BaseUrisProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Common/AsyncEnumerableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Common/Direction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Common/Models/ListSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Common/Models/ListSegmentMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Common/Models/ListingCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Common/Models/ListingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Credits/CreditsRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Credits/ICreditsRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Credits/Models/Balance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
2 changes: 1 addition & 1 deletion source/Verifalia.Api/Credits/Models/DailyUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://verifalia.com/
* [email protected]
*
* Copyright (c) 2005-2020 Cobisi Research
* Copyright (c) 2005-2021 Cobisi Research
*
* Cobisi Research
* Via Della Costituzione, 31
Expand Down
Loading

0 comments on commit 8d693f0

Please sign in to comment.