Skip to content

Commit 353515c

Browse files
committed
Change AsyncConsumer test to use Async.Yield
instead of Task.FromResult(0). Make tests sync.
1 parent c68d793 commit 353515c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

projects/client/Unit/src/unit/TestAsyncConsumer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class TestAsyncConsumer
6060
{
6161

6262
[Test]
63-
public async Task TestBasicRoundtrip()
63+
public void TestBasicRoundtrip()
6464
{
6565
var cf = new ConnectionFactory{ DispatchConsumersAsync = true };
6666
using(var c = cf.CreateConnection())
@@ -71,20 +71,20 @@ public async Task TestBasicRoundtrip()
7171
var body = System.Text.Encoding.UTF8.GetBytes("async-hi");
7272
m.BasicPublish("", q.QueueName, bp, body);
7373
var consumer = new AsyncEventingBasicConsumer(m);
74-
var sem = new SemaphoreSlim(0);
74+
var are = new AutoResetEvent(false);
7575
consumer.Received += async (o, a) =>
7676
{
77-
sem.Release();
78-
await Task.FromResult(0);
77+
are.Set();
78+
await Task.Yield();
7979
};
8080
var tag = m.BasicConsume(q.QueueName, true, consumer);
8181
// ensure we get a delivery
82-
var waitRes = await sem.WaitAsync(2000);
82+
var waitRes = are.WaitOne(2000);
8383
Assert.IsTrue(waitRes);
8484
// unsubscribe and ensure no further deliveries
8585
m.BasicCancel(tag);
8686
m.BasicPublish("", q.QueueName, bp, body);
87-
var waitResFalse = await sem.WaitAsync(100);
87+
var waitResFalse = are.WaitOne(2000);
8888
Assert.IsFalse(waitResFalse);
8989
}
9090
}

0 commit comments

Comments
 (0)