Skip to content

Commit ef479bc

Browse files
committed
Cosmetic (layout, brace alignment)
1 parent 40fc1a0 commit ef479bc

File tree

1 file changed

+48
-43
lines changed

1 file changed

+48
-43
lines changed

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

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@
5050
using RabbitMQ.Client.Events;
5151
using RabbitMQ.Client.MessagePatterns;
5252

53-
namespace RabbitMQ.Client.Unit {
53+
namespace RabbitMQ.Client.Unit
54+
{
5455
[TestFixture]
55-
public class TestMessagePatternsSubscription : IntegrationFixture {
56+
public class TestMessagePatternsSubscription : IntegrationFixture
57+
{
5658
UTF8Encoding enc = new UTF8Encoding();
5759

5860
[Test]
@@ -90,6 +92,44 @@ public void TestSubscriptionNack()
9092
TestSubscriptionAction((s) => s.Nack(false, false));
9193
}
9294

95+
[Test]
96+
public void TestConcurrentIterationAndAck()
97+
{
98+
TestConcurrentIterationWithDrainer((s) => s.Ack());
99+
}
100+
101+
[Test]
102+
public void TestConcurrentIterationAndNack()
103+
{
104+
TestConcurrentIterationWithDrainer((s) => s.Nack(false, false));
105+
}
106+
107+
protected void TestConcurrentIterationWithDrainer(SubscriptionAction act)
108+
{
109+
IDictionary<string, object> args = new Dictionary<string, object>
110+
{
111+
{"x-message-ttl", 5000}
112+
};
113+
string q = Model.QueueDeclare("", false, true, false, args);
114+
Subscription sub = new Subscription(Model, q, false);
115+
116+
PreparedQueue(q);
117+
118+
List<Thread> ts = new List<Thread>();
119+
for (int i = 0; i < 50; i++)
120+
{
121+
SubscriptionDrainer drainer = new SubscriptionDrainer(sub, act);
122+
Thread t = new Thread(drainer.Drain);
123+
ts.Add(t);
124+
t.Start();
125+
}
126+
127+
foreach(Thread t in ts)
128+
{
129+
t.Join();
130+
}
131+
}
132+
93133
private void TestSubscriptionAction(SubscriptionAction action)
94134
{
95135
Model.BasicQos(0, 1, false);
@@ -129,15 +169,18 @@ public void Drain()
129169
{
130170
Assert.That(ea, Is.TypeOf(typeof(BasicDeliverEventArgs)));
131171
this.PostProcess(m_subscription);
132-
} else
172+
}
173+
else
133174
{
134175
break;
135176
}
136177
}
137-
} catch (AlreadyClosedException ace)
178+
}
179+
catch (AlreadyClosedException ace)
138180
{
139181
// expected
140-
} finally
182+
}
183+
finally
141184
{
142185
m_subscription.Close();
143186
}
@@ -146,44 +189,6 @@ public void Drain()
146189
}
147190
}
148191

149-
[Test]
150-
public void TestConcurrentIterationAndAck()
151-
{
152-
TestConcurrentIterationWithDrainer((s) => s.Ack());
153-
}
154-
155-
[Test]
156-
public void TestConcurrentIterationAndNack()
157-
{
158-
TestConcurrentIterationWithDrainer((s) => s.Nack(false, false));
159-
}
160-
161-
protected void TestConcurrentIterationWithDrainer(SubscriptionAction act)
162-
{
163-
IDictionary<string, object> args = new Dictionary<string, object>
164-
{
165-
{"x-message-ttl", 5000}
166-
};
167-
string q = Model.QueueDeclare("", false, true, false, args);
168-
Subscription sub = new Subscription(Model, q, false);
169-
170-
PreparedQueue(q);
171-
172-
List<Thread> ts = new List<Thread>();
173-
for (int i = 0; i < 50; i++)
174-
{
175-
SubscriptionDrainer drainer = new SubscriptionDrainer(sub, act);
176-
Thread t = new Thread(drainer.Drain);
177-
ts.Add(t);
178-
t.Start();
179-
}
180-
181-
foreach(Thread t in ts)
182-
{
183-
t.Join();
184-
}
185-
}
186-
187192
private void PreparedQueue(string q)
188193
{
189194
for (int i = 0; i < 1024; i++)

0 commit comments

Comments
 (0)