Skip to content

Commit 55293dd

Browse files
committed
Add [Collection("IntegrationFixture")] to test class that needs it, move test to an integration fixture class
1 parent eaa76c8 commit 55293dd

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

projects/Unit/TestBasicProperties.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -192,44 +192,5 @@ public void TestProperties_ReplyTo(string replyTo)
192192
Assert.Equal(isReplyToPresent, basicProperties.IsReplyToPresent());
193193
Assert.Equal(replyToAddress, basicProperties.ReplyToAddress?.ToString());
194194
}
195-
196-
[Fact]
197-
public void TestPropertiesRountrip_Headers()
198-
{
199-
// Arrange
200-
var subject = new BasicProperties
201-
{
202-
Headers = new Dictionary<string, object>()
203-
};
204-
205-
var cf = new ConnectionFactory();
206-
using (IConnection c = cf.CreateConnection())
207-
using (IChannel m = c.CreateChannel())
208-
{
209-
QueueDeclareOk q = m.QueueDeclare();
210-
var bp = new BasicProperties() { Headers = new Dictionary<string, object>() };
211-
bp.Headers["Hello"] = "World";
212-
byte[] sendBody = Encoding.UTF8.GetBytes("hi");
213-
byte[] consumeBody = null;
214-
var consumer = new EventingBasicConsumer(m);
215-
var are = new AutoResetEvent(false);
216-
string response = null;
217-
consumer.Received += async (o, a) =>
218-
{
219-
response = Encoding.UTF8.GetString(a.BasicProperties.Headers["Hello"] as byte[]);
220-
consumeBody = a.Body.ToArray();
221-
are.Set();
222-
await Task.Yield();
223-
};
224-
225-
string tag = m.BasicConsume(q.QueueName, true, consumer);
226-
m.BasicPublish("", q.QueueName, bp, sendBody);
227-
bool waitResFalse = are.WaitOne(5000);
228-
m.BasicCancel(tag);
229-
Assert.True(waitResFalse);
230-
Assert.Equal(sendBody, consumeBody);
231-
Assert.Equal("World", response);
232-
}
233-
}
234195
}
235196
}

projects/Unit/TestBasicPublish.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//---------------------------------------------------------------------------
3131

3232
using System;
33+
using System.Collections.Generic;
3334
using System.Text;
3435
using System.Threading;
3536
using System.Threading.Tasks;
@@ -252,5 +253,44 @@ public void TestMaxMessageSize()
252253
}
253254
}
254255
}
256+
257+
[Fact]
258+
public void TestPropertiesRountrip_Headers()
259+
{
260+
// Arrange
261+
var subject = new BasicProperties
262+
{
263+
Headers = new Dictionary<string, object>()
264+
};
265+
266+
var cf = new ConnectionFactory();
267+
using (IConnection c = cf.CreateConnection())
268+
using (IChannel m = c.CreateChannel())
269+
{
270+
QueueDeclareOk q = m.QueueDeclare();
271+
var bp = new BasicProperties() { Headers = new Dictionary<string, object>() };
272+
bp.Headers["Hello"] = "World";
273+
byte[] sendBody = Encoding.UTF8.GetBytes("hi");
274+
byte[] consumeBody = null;
275+
var consumer = new EventingBasicConsumer(m);
276+
var are = new AutoResetEvent(false);
277+
string response = null;
278+
consumer.Received += async (o, a) =>
279+
{
280+
response = Encoding.UTF8.GetString(a.BasicProperties.Headers["Hello"] as byte[]);
281+
consumeBody = a.Body.ToArray();
282+
are.Set();
283+
await Task.Yield();
284+
};
285+
286+
string tag = m.BasicConsume(q.QueueName, true, consumer);
287+
m.BasicPublish("", q.QueueName, bp, sendBody);
288+
bool waitResFalse = are.WaitOne(5000);
289+
m.BasicCancel(tag);
290+
Assert.True(waitResFalse);
291+
Assert.Equal(sendBody, consumeBody);
292+
Assert.Equal("World", response);
293+
}
294+
}
255295
}
256296
}

projects/Unit/TestConnectionFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
namespace RabbitMQ.Client.Unit
3737
{
38+
[Collection("IntegrationFixture")]
3839
public class TestConnectionFactory
3940
{
4041
[Fact]

0 commit comments

Comments
 (0)