Skip to content

Commit

Permalink
Bump the xunit group with 1 update (#1769)
Browse files Browse the repository at this point in the history
* Bump the xunit group with 1 update

Bumps the xunit group with 1 update: [xunit](https://github.com/xunit/xunit).

- [Commits](xunit/xunit@2.5.3...2.6.0)

---
updated-dependencies:
- dependency-name: xunit
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xunit
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix CS0121 errors

Fix CS0121 errors caused by ambiguity between `Task` and `ValueTask`.

* Fix compiler errors

Fix compiler errors again by forcing the Func<Task> overload to be used.

* Suppress xUnit1031 warnings

Suppress xUnit1031 warnings that are OK because we explicitly want to wait for the operation to not succeed.

* Refactor workaround

Rename method and drop type argument.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: martincostello <[email protected]>
  • Loading branch information
dependabot[bot] and martincostello authored Nov 2, 2023
1 parent 381a01f commit 9e86a0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<PackageVersion Include="System.Threading.RateLimiting" Version="$(MicrosoftExtensionsVersion)" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="xunit" Version="2.5.3" />
<PackageVersion Include="xunit" Version="2.6.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework) == 'net6.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ public async Task Disposed_EnsureThrows()
Assert.Throws<ObjectDisposedException>(() => controller.LastException);
Assert.Throws<ObjectDisposedException>(() => controller.LastHandledOutcome);

await Assert.ThrowsAsync<ObjectDisposedException>(async () => await controller.CloseCircuitAsync(ResilienceContextPool.Shared.Get()));
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await controller.IsolateCircuitAsync(ResilienceContextPool.Shared.Get()));
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await controller.OnActionPreExecuteAsync(ResilienceContextPool.Shared.Get()));
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await controller.OnActionSuccessAsync(Outcome.FromResult(10), ResilienceContextPool.Shared.Get()));
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await controller.OnActionFailureAsync(Outcome.FromResult(10), ResilienceContextPool.Shared.Get()));
// xunit 2.6.0 has Func<ValueTask> and Func<Task> overloads that cause ambiguity which
// is messy to resolve for multiple different TFMs, so force the Task version to be used.
static async Task AssertThrowsObjectDisposedExceptionAsync(Func<Task> func)
=> await Assert.ThrowsAsync<ObjectDisposedException>(func);

await AssertThrowsObjectDisposedExceptionAsync(async () => await controller.CloseCircuitAsync(ResilienceContextPool.Shared.Get()));
await AssertThrowsObjectDisposedExceptionAsync(async () => await controller.IsolateCircuitAsync(ResilienceContextPool.Shared.Get()));
await AssertThrowsObjectDisposedExceptionAsync(async () => await controller.OnActionPreExecuteAsync(ResilienceContextPool.Shared.Get()));
await AssertThrowsObjectDisposedExceptionAsync(async () => await controller.OnActionSuccessAsync(Outcome.FromResult(10), ResilienceContextPool.Shared.Get()));
await AssertThrowsObjectDisposedExceptionAsync(async () => await controller.OnActionFailureAsync(Outcome.FromResult(10), ResilienceContextPool.Shared.Get()));
}

[Fact]
Expand Down Expand Up @@ -193,7 +198,9 @@ public async Task OnActionFailure_EnsureLock()
var executeAction2 = Task.Run(() => controller.OnActionFailureAsync(Outcome.FromResult(0), ResilienceContextPool.Shared.Get()));

// assert
#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
executeAction.Wait(50).Should().BeFalse();
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
verified.Set();
await executeAction;
await executeAction2;
Expand Down Expand Up @@ -412,7 +419,9 @@ public async Task ExecuteScheduledTask_Async_Ok()
var source = new TaskCompletionSource<string>();
var task = CircuitStateController<string>.ExecuteScheduledTaskAsync(source.Task, ResilienceContextPool.Shared.Get().Initialize<string>(isSynchronous: false)).AsTask();

#pragma warning disable xUnit1031 // Do not use blocking task operations in test method
task.Wait(3).Should().BeFalse();
#pragma warning restore xUnit1031 // Do not use blocking task operations in test method
task.IsCompleted.Should().BeFalse();

source.SetResult("ok");
Expand Down

0 comments on commit 9e86a0a

Please sign in to comment.