Skip to content

Commit

Permalink
* Add wait on RegisteredAsync to see how the changes in #1750 affec…
Browse files Browse the repository at this point in the history
…t the order of operations.
  • Loading branch information
lukebakken committed Jan 3, 2025
1 parent dc6a3f4 commit b021daa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions projects/Test/Integration/TestAsyncConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public async Task TestBasicRoundtripConcurrent()

var consumer = new AsyncEventingBasicConsumer(_channel);

var consumerRegisteredTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var publish1SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var publish2SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);

Expand Down Expand Up @@ -105,6 +106,20 @@ public async Task TestBasicRoundtripConcurrent()
return Task.CompletedTask;
};

consumer.RegisteredAsync += (object sender, ConsumerEventArgs ea) =>
{
if (ReferenceEquals(consumer, sender))
{
consumerRegisteredTcs.SetResult(true);
}
else
{
var ex = Xunit.Sdk.EqualException.ForMismatchedValues(consumer, sender);
consumerRegisteredTcs.SetException(ex);
}
return Task.CompletedTask;
};

consumer.ReceivedAsync += (o, a) =>
{
if (ByteArraysEqual(a.Body.Span, body1))
Expand All @@ -126,6 +141,7 @@ public async Task TestBasicRoundtripConcurrent()
};

await _channel.BasicConsumeAsync(q.QueueName, true, string.Empty, false, false, null, consumer);
await consumerRegisteredTcs.Task.WaitAsync(WaitSpan);

try
{
Expand Down

0 comments on commit b021daa

Please sign in to comment.