Skip to content

Commit

Permalink
Fix: Make Event Hub PartitionReceiver tests more robust (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-pajurek authored Oct 11, 2024
1 parent ecd8a5f commit df6475c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/Tests/EventHub/PartitionReceiverTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Text.RegularExpressions;

using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Consumer;
using Azure.Messaging.EventHubs.Producer;
Expand Down Expand Up @@ -321,12 +323,16 @@ public async Task Starting_Position_Higher_Than_Latest_Event_Should_Fail()

var expectedMessage = $"" +
$"The supplied sequence number '{startingPositionSequenceNumber}' is invalid. " +
$"The last sequence number in the system is '{lastEnqueuedSequenceNumber}'";
$"The last sequence number in the system is '";

await act
.Should()
.ThrowAsync<ArgumentException>()
.Where(e => e.Message.StartsWith(expectedMessage));
var exception = await act
.Should()
.ThrowAsync<ArgumentException>()
.Where(e => e.Message.StartsWith(expectedMessage));

var actualLastEnqueuedSequenceNumber = long.Parse(Regex.Match(exception.Which.Message, @"The last sequence number in the system is '(\d+)'").Groups[1].Value);

actualLastEnqueuedSequenceNumber.Should().BeGreaterThanOrEqualTo(lastEnqueuedSequenceNumber);
}

[TestMethod]
Expand Down

0 comments on commit df6475c

Please sign in to comment.