Skip to content

Commit 320b274

Browse files
author
Emile Joubert
committed
Confirm publish before checking queue size in test
The message count reported by queue.declare could be wrong otherwise, because queue declare may overtake a publish.
1 parent 81b77f2 commit 320b274

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
//---------------------------------------------------------------------------
4040

4141
using System;
42+
using System.Threading;
4243
using NUnit.Framework;
4344
using RabbitMQ.Client.Exceptions;
4445

@@ -53,13 +54,17 @@ public class TestComplexResults : IntegrationFixture
5354
[Test]
5455
public void TestQueueDeclareOk()
5556
{
57+
AutoResetEvent excl = new AutoResetEvent(false);
58+
Model.ConfirmSelect();
59+
Model.BasicAcks += delegate { excl.Set(); };
5660
QueueDeclareOk result;
5761

5862
result = QueueDeclare();
5963
Assert.AreEqual(0, result.MessageCount);
6064
Assert.AreEqual(0, result.ConsumerCount);
6165
Assert.AreEqual(QueueName, result.QueueName);
6266
Model.BasicPublish("", result.QueueName, null, new byte[] { });
67+
excl.WaitOne();
6368

6469
result = QueueDeclare();
6570
Assert.AreEqual(1, result.MessageCount);

0 commit comments

Comments
 (0)