Skip to content

Commit 27a2ebe

Browse files
committed
Verify connection shutdown cancellation propagation
1 parent 563fb94 commit 27a2ebe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

projects/Test/Integration/TestConnectionShutdown.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ public async Task TestShutdownSignalPropagationToChannels()
162162
await WaitAsync(tcs, TimeSpan.FromSeconds(3), "channel shutdown");
163163
}
164164

165+
[Fact]
166+
public async Task TestShutdownCancellation()
167+
{
168+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1));
169+
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
170+
171+
_conn.ConnectionShutdownAsync += async (channel, args) =>
172+
{
173+
try
174+
{
175+
await Task.Delay(TimeSpan.FromMinutes(1), args.CancellationToken);
176+
}
177+
catch (OperationCanceledException)
178+
{
179+
tcs.SetResult(true);
180+
}
181+
};
182+
183+
await _conn.CloseAsync(cancellationToken: cts.Token);
184+
185+
await WaitAsync(tcs, TimeSpan.FromSeconds(3), "connection shutdown");
186+
}
187+
165188
[Fact]
166189
public async Task TestShutdownSignalPropagationWithCancellationToChannels()
167190
{

0 commit comments

Comments
 (0)