Skip to content

Commit 8d8c23b

Browse files
One more test, refactor
1 parent ea8f5cd commit 8d8c23b

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,41 @@ public class TestPublisherConfirms : IntegrationFixture
4949
{
5050
[Test]
5151
public void TestWaitForConfirmsWithoutTimeout()
52+
{
53+
TestWaitForConfirms(200, (ch) =>
54+
{
55+
Assert.IsTrue(ch.WaitForConfirms());
56+
});;
57+
}
58+
59+
[Test]
60+
public void TestWaitForConfirmsWithTimeout()
61+
{
62+
TestWaitForConfirms(200, (ch) =>
63+
{
64+
Assert.IsTrue(ch.WaitForConfirms(TimeSpan.FromSeconds(4)));
65+
}); ;
66+
}
67+
68+
protected void TestWaitForConfirms(int numberOfMessagesToPublish, Action<IModel> fn)
5269
{
5370
var ch = Conn.CreateModel();
5471
ch.ConfirmSelect();
5572

5673
var q = ch.QueueDeclare().QueueName;
5774

58-
for (int i = 0; i < 200; i++)
75+
for (int i = 0; i < numberOfMessagesToPublish; i++)
5976
{
6077
ch.BasicPublish("", q, null, encoding.GetBytes("msg"));
6178
}
62-
Assert.IsTrue(ch.WaitForConfirms());
63-
ch.QueueDelete(q);
64-
ch.Close();
79+
try
80+
{
81+
fn(ch);
82+
} finally
83+
{
84+
ch.QueueDelete(q);
85+
ch.Close();
86+
}
6587
}
6688
}
6789
}

0 commit comments

Comments
 (0)