Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 31eede4

Browse files
committed
Remove order implied by Assert.Collection()
Adding extra info to identify why the test is failing on full framework
1 parent 0399c7d commit 31eede4

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

test/Microsoft.Azure.ServiceBus.UnitTests/SenderReceiverTests.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.Linq;
5-
64
namespace Microsoft.Azure.ServiceBus.UnitTests
75
{
86
using System;
7+
using System.Linq;
98
using System.Text;
109
using System.Collections.Generic;
1110
using System.Threading;
@@ -470,9 +469,9 @@ public async Task Sending_batch()
470469
var receiver = new MessageReceiver(TestUtility.NamespaceConnectionString, TestConstants.PartitionedQueueName, receiveMode: ReceiveMode.ReceiveAndDelete);
471470
try
472471
{
473-
var message1 = new Message(Encoding.UTF8.GetBytes("Hello Neeraj"));
474-
var message2 = new Message(Encoding.UTF8.GetBytes("from"));
475-
var message3 = new Message(Encoding.UTF8.GetBytes("Sean Feldman"));
472+
var message1 = new Message("Hello Neeraj".GetBytes());
473+
var message2 = new Message("from".GetBytes());
474+
var message3 = new Message("Sean Feldman".GetBytes());
476475

477476
var batch = new Batch(100);
478477
Assert.True(batch.TryAdd(message1), "Couldn't add first message");
@@ -483,12 +482,12 @@ public async Task Sending_batch()
483482
await sender.CloseAsync();
484483

485484
var receivedMessages = await TestUtility.ReceiveMessagesAsync(receiver, 2);
486-
var bodies = receivedMessages.Select(m => Encoding.UTF8.GetString(m.Body));
487-
Assert.Collection(bodies, item => Assert.Contains("Hello Neeraj", item),
488-
item => Assert.Contains("from", item));
485+
var bodies = receivedMessages.Select(m => m.Body.GetString());
486+
var bodiesArray = bodies as string[] ?? bodies.ToArray();
487+
Assert.True(bodiesArray.Contains("Hello Neeraj") && bodiesArray.Contains("from"));
489488

490489
var extraMessage = await TestUtility.PeekMessageAsync(receiver);
491-
Assert.True(extraMessage == null, "Should not have any messages other than the two, but an extra message is found");
490+
Assert.True(extraMessage == null, $"Should not have any messages other than the two, but an extra message is found. Body='{extraMessage?.Body.GetString()}'");
492491
}
493492
finally
494493
{

0 commit comments

Comments
 (0)