diff --git a/Directory.Packages.props b/Directory.Packages.props index 55bb6cb..60ad5be 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -16,7 +16,7 @@ - + diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/NetEvolve.Extensions.Tasks.Tests.Unit.csproj b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/NetEvolve.Extensions.Tasks.Tests.Unit.csproj index f149be3..c15f8a1 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/NetEvolve.Extensions.Tasks.Tests.Unit.csproj +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/NetEvolve.Extensions.Tasks.Tests.Unit.csproj @@ -1,9 +1,11 @@ - net5.0;net6.0;net7.0;net8.0 + net6.0;net7.0;net8.0 - $(NoWarn);VSTHRD003; + $(NoWarn);VSTHRD003;NU1701; + + true diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,Timespan).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,Timespan).cs index 192b225..2f94af7 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,Timespan).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,Timespan).cs @@ -16,15 +16,10 @@ public async Task WithTimeoutAsync_ParamTaskNull_ArgumentNullException() { Task task = null!; - _ = await Assert - .ThrowsAsync( - "task", - async () => - await task! - .WithTimeoutAsync(TimeSpan.FromMilliseconds(100)) - .ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "task", + async () => await task!.WithTimeoutAsync(TimeSpan.FromMilliseconds(100)) + ); } [Fact] @@ -32,12 +27,12 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeout = TimeSpan.FromMilliseconds(75); - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); static async Task TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return; } } @@ -47,12 +42,12 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeout = TimeSpan.FromMilliseconds(20); - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -62,7 +57,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeout = TimeSpan.FromMilliseconds(100); - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); static Task TestMethod() => Task.CompletedTask; @@ -73,12 +68,12 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeout = Timeout.InfiniteTimeSpan; - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -88,12 +83,12 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeout = TimeSpan.Zero; - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -103,16 +98,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowArgumentOutOfRangeExcept { var timeout = new TimeSpan(0, 0, 0, 0, -2); - _ = await Assert - .ThrowsAsync( - "timeout", - async () => await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeout", + async () => await TestMethod().WithTimeoutAsync(timeout) + ); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,int).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,int).cs index cec81e1..c4d7a7d 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,int).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(Task,int).cs @@ -16,12 +16,10 @@ public async Task WithTimeoutAsync_ParamTaskNull_ArgumentNullException() { Task task = null!; - _ = await Assert - .ThrowsAsync( - "task", - async () => await task!.WithTimeoutAsync(100).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "task", + async () => await task!.WithTimeoutAsync(100) + ); } [Fact] @@ -29,16 +27,10 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeoutInMilliseconds = 75; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); - static async Task TestMethod() - { - await Task.Delay(20).ConfigureAwait(false); - return; - } + static Task TestMethod() => Task.Delay(20); } [Fact] @@ -46,16 +38,10 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeoutInMilliseconds = 20; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); - static async Task TestMethod() - { - await Task.Delay(75).ConfigureAwait(false); - return; - } + static Task TestMethod() => Task.Delay(75); } [Fact] @@ -63,9 +49,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeoutInMilliseconds = 75; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); static Task TestMethod() => Task.CompletedTask; @@ -76,16 +60,10 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeoutInMilliseconds = Timeout.Infinite; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); - static async Task TestMethod() - { - await Task.Delay(75).ConfigureAwait(false); - return; - } + static Task TestMethod() => Task.Delay(75); } [Fact] @@ -93,16 +71,10 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeoutInMilliseconds = 0; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); - static async Task TestMethod() - { - await Task.Delay(75).ConfigureAwait(false); - return; - } + static Task TestMethod() => Task.Delay(75); } [Fact] @@ -110,18 +82,11 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowArgumentOutOfRangeExcept { var timeoutInMilliseconds = -2; - _ = await Assert - .ThrowsAsync( - "timeoutInMilliseconds", - async () => - await TestMethod().WithTimeoutAsync(timeoutInMilliseconds).ConfigureAwait(false) - ) - .ConfigureAwait(false); - - static async Task TestMethod() - { - await Task.Delay(75).ConfigureAwait(false); - return; - } + _ = await Assert.ThrowsAsync( + "timeoutInMilliseconds", + async () => await TestMethod().WithTimeoutAsync(timeoutInMilliseconds) + ); + + static Task TestMethod() => Task.Delay(75); } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,Timespan).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,Timespan).cs index a9552d7..1097165 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,Timespan).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,Timespan).cs @@ -16,15 +16,10 @@ public async Task WithTimeoutAsync_ParamTaskNull_ArgumentNullException() { Task task = null!; - _ = await Assert - .ThrowsAsync( - "task", - async () => - await task! - .WithTimeoutAsync(TimeSpan.FromMilliseconds(100)) - .ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "task", + async () => await task!.WithTimeoutAsync(TimeSpan.FromMilliseconds(100)) + ); } [Fact] @@ -32,13 +27,13 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeout = TimeSpan.FromMilliseconds(75); - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return 1; } } @@ -48,13 +43,13 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeout = TimeSpan.FromMilliseconds(20); - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -64,7 +59,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeout = TimeSpan.FromMilliseconds(20); - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); Assert.Equal(1, result); @@ -76,13 +71,13 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeout = Timeout.InfiniteTimeSpan; - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -92,13 +87,13 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeout = TimeSpan.Zero; - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -108,16 +103,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowsArgumentOutOfRangeExcep { var timeout = new TimeSpan(0, 0, 0, 0, -2); - _ = await Assert - .ThrowsAsync( - "timeout", - async () => await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeout", + async () => await TestMethod().WithTimeoutAsync(timeout) + ); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,int).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,int).cs index cd7e086..0c62559 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,int).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(TaskOfT,int).cs @@ -16,12 +16,10 @@ public async Task WithTimeoutAsync_ParamTaskNull_ArgumentNullException() { Task task = null!; - _ = await Assert - .ThrowsAsync( - "task", - async () => await task!.WithTimeoutAsync(100).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "task", + async () => await task!.WithTimeoutAsync(100) + ); } [Fact] @@ -29,15 +27,13 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeoutInMilliseconds = 75; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return 1; } } @@ -47,15 +43,13 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeoutInMilliseconds = 20; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -65,9 +59,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeoutInMilliseconds = 20; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); Assert.Equal(1, result); @@ -79,15 +71,13 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeoutInMilliseconds = Timeout.Infinite; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -97,15 +87,13 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeoutInMilliseconds = 0; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); Assert.Equal(1, result); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -115,17 +103,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowsArgumentOutOfRangeExcep { var timeoutInMilliseconds = -2; - _ = await Assert - .ThrowsAsync( - "timeoutInMilliseconds", - async () => - await TestMethod().WithTimeoutAsync(timeoutInMilliseconds).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeoutInMilliseconds", + async () => await TestMethod().WithTimeoutAsync(timeoutInMilliseconds) + ); static async Task TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,Timespan).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,Timespan).cs index 5a2eca6..cf38194 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,Timespan).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,Timespan).cs @@ -16,12 +16,12 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeout = TimeSpan.FromMilliseconds(75); - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); static async ValueTask TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return; } } @@ -31,12 +31,12 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeout = TimeSpan.FromMilliseconds(20); - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -46,7 +46,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeout = TimeSpan.FromMilliseconds(75); - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); static ValueTask TestMethod() => ValueTask.CompletedTask; @@ -57,12 +57,12 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeout = Timeout.InfiniteTimeSpan; - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -72,12 +72,12 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeout = TimeSpan.Zero; - var isValid = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -87,16 +87,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowArgumentOutOfRangeExcept { var timeout = new TimeSpan(0, 0, 0, 0, -2); - _ = await Assert - .ThrowsAsync( - "timeout", - async () => await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeout", + async () => await TestMethod().WithTimeoutAsync(timeout) + ); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,int).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,int).cs index 7e4a278..53fe07e 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,int).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTask,int).cs @@ -16,14 +16,12 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeoutInMilliseconds = 75; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); static async ValueTask TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return; } } @@ -33,14 +31,12 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeoutInMilliseconds = 20; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -50,9 +46,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeoutInMilliseconds = 75; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); static ValueTask TestMethod() => ValueTask.CompletedTask; @@ -63,14 +57,12 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeoutInMilliseconds = Timeout.Infinite; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -80,14 +72,12 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeoutInMilliseconds = 0; - var isValid = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var isValid = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } @@ -97,17 +87,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowArgumentOutOfRangeExcept { var timeoutInMilliseconds = -2; - _ = await Assert - .ThrowsAsync( - "timeoutInMilliseconds", - async () => - await TestMethod().WithTimeoutAsync(timeoutInMilliseconds).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeoutInMilliseconds", + async () => await TestMethod().WithTimeoutAsync(timeoutInMilliseconds) + ); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return; } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,Timespan).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,Timespan).cs index b370b97..07ec830 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,Timespan).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,Timespan).cs @@ -16,13 +16,13 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeout = TimeSpan.FromMilliseconds(75); - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return 1; } } @@ -32,13 +32,13 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeout = TimeSpan.FromMilliseconds(20); - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -48,7 +48,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeout = TimeSpan.FromMilliseconds(20); - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); Assert.Equal(1, result); @@ -60,13 +60,13 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeout = Timeout.InfiniteTimeSpan; - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.True(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -76,13 +76,13 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeout = TimeSpan.Zero; - var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeout); Assert.False(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -92,16 +92,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowArgumentOutOfRangeExcept { var timeout = new TimeSpan(0, 0, 0, 0, -2); - _ = await Assert - .ThrowsAsync( - "timeout", - async () => await TestMethod().WithTimeoutAsync(timeout).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeout", + async () => await TestMethod().WithTimeoutAsync(timeout) + ); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } diff --git a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,int).cs b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,int).cs index 508db2d..b2a2eeb 100644 --- a/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,int).cs +++ b/tests/NetEvolve.Extensions.Tasks.Tests.Unit/WithTimeoutAsync(ValueTaskOfT,int).cs @@ -16,15 +16,13 @@ public async Task WithTimeoutAsync_IsValidTrue_Expected() { var timeoutInMilliseconds = 75; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(20).ConfigureAwait(false); + await Task.Delay(20); return 1; } } @@ -34,15 +32,13 @@ public async Task WithTimeoutAsync_IsValidFalse_Expected() { var timeoutInMilliseconds = 20; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -52,9 +48,7 @@ public async Task WithTimeoutAsync_TaskAlreadyCompleted_Expected() { var timeoutInMilliseconds = 20; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); Assert.Equal(1, result); @@ -66,15 +60,13 @@ public async Task WithTimeoutAsync_TimeoutInfinite_Expected() { var timeoutInMilliseconds = Timeout.Infinite; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.True(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -84,15 +76,13 @@ public async Task WithTimeoutAsync_TimeoutZero_Expected() { var timeoutInMilliseconds = 0; - var (isValid, result) = await TestMethod() - .WithTimeoutAsync(timeoutInMilliseconds) - .ConfigureAwait(false); + var (isValid, result) = await TestMethod().WithTimeoutAsync(timeoutInMilliseconds); Assert.False(isValid); Assert.Equal(1, result); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } } @@ -102,17 +92,14 @@ public async Task WithTimeoutAsync_TimeoutMinusTwo_ThrowArgumentOutOfRangeExcept { var timeoutInMilliseconds = -2; - _ = await Assert - .ThrowsAsync( - "timeoutInMilliseconds", - async () => - await TestMethod().WithTimeoutAsync(timeoutInMilliseconds).ConfigureAwait(false) - ) - .ConfigureAwait(false); + _ = await Assert.ThrowsAsync( + "timeoutInMilliseconds", + async () => await TestMethod().WithTimeoutAsync(timeoutInMilliseconds) + ); static async ValueTask TestMethod() { - await Task.Delay(75).ConfigureAwait(false); + await Task.Delay(75); return 1; } }