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

Commit 4292a5b

Browse files
committed
Modify test to remove reliance on order of messages
1 parent 95d0f7b commit 4292a5b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
namespace Microsoft.Azure.ServiceBus.UnitTests
57
{
68
using System;
@@ -477,12 +479,14 @@ public async Task Sending_batch()
477479
Assert.True(batch.TryAdd(message2), "Couldn't add second message");
478480
Assert.False(batch.TryAdd(message3), "Shouldn't be able to add third message");
479481
await sender.SendAsync(batch);
480-
//batch.dispose()
482+
batch.Dispose();
481483
await sender.CloseAsync();
482484

483485
var receivedMessages = await TestUtility.ReceiveMessagesAsync(receiver, 2);
484-
Assert.Equal("Hello Neeraj", Encoding.UTF8.GetString(receivedMessages[0].Body));
485-
Assert.Equal("from", Encoding.UTF8.GetString(receivedMessages[1].Body));
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));
489+
486490
var extraMessage = await TestUtility.PeekMessageAsync(receiver);
487491
Assert.True(extraMessage == null, "Should not have any messages other than the two, but an extra message is found");
488492
}

0 commit comments

Comments
 (0)