refactor(link): bound every teardown and handler wait behind one helper [CI]
This commit is contained in:
1 parent
c05842fd91
commit
d95acc6575
10 files changed
+130
-31
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using Fleet.Core;
|
||||
|
||||
namespace Fleet.Tests;
|
||||
|
||||
public sealed class BoundedTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task WaitAsync_ReturnsFalse_WhenTheWorkNeverFinishes()
|
||||
{
|
||||
var never = new TaskCompletionSource();
|
||||
Assert.False(await Bounded.WaitAsync(never.Task, TimeSpan.FromMilliseconds(100), TimeProvider.System));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WaitAsync_ReturnsTrue_WhenTheWorkFinishes_OrFailsWithSessionNoise()
|
||||
{
|
||||
Assert.True(await Bounded.WaitAsync(Task.CompletedTask, TimeSpan.FromSeconds(5), TimeProvider.System));
|
||||
Assert.True(await Bounded.WaitAsync(Task.FromException(new IOException("closed")), TimeSpan.FromSeconds(5), TimeProvider.System));
|
||||
Assert.True(await Bounded.WaitAsync(Task.FromException(new ObjectDisposedException("x")), TimeSpan.FromSeconds(5), TimeProvider.System));
|
||||
Assert.True(await Bounded.WaitAsync(Task.FromCanceled(new CancellationToken(true)), TimeSpan.FromSeconds(5), TimeProvider.System));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WaitAsync_DoesNotHideRealFailures()
|
||||
{
|
||||
await Assert.ThrowsAsync<FormatException>(() => Bounded.WaitAsync(Task.FromException(new FormatException()), TimeSpan.FromSeconds(5), TimeProvider.System));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user