Skip to content

Commit 5890f31

Browse files
authored
[Event Hubs Client] Fix Flaky Procesor Test (Azure#21441)
The focus of these changes is to fix a flaky test resulting from a recent change to the sequence of events when an event processor is closed.
1 parent 22130a4 commit 5890f31

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sdk/eventhub/Azure.Messaging.EventHubs/tests/Primitives/EventProcessorTests.PartitionProcessing.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,22 @@ public async Task CreatePartitionProcessorDoesNotAllowReadingLastEventProperties
232232

233233
var completionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
234234
var options = new EventProcessorOptions { TrackLastEnqueuedEventProperties = true };
235+
var mockConsumer = new Mock<TransportConsumer>();
235236
var mockConnection = Mock.Of<EventHubConnection>();
236237
var mockProcessor = new Mock<EventProcessor<EventProcessorPartition>>(5, "consumerGroup", "namespace", "eventHub", Mock.Of<TokenCredential>(), options) { CallBase = true };
237238

239+
mockConsumer
240+
.SetupGet(consumer => consumer.IsClosed)
241+
.Returns(true);
242+
238243
mockProcessor
239244
.Setup(processor => processor.CreateConnection())
240245
.Returns(mockConnection);
241246

242247
mockProcessor
243248
.Setup(processor => processor.CreateConsumer(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<EventPosition>(), mockConnection, It.IsAny<EventProcessorOptions>()))
244-
.Returns(default(TransportConsumer))
245-
.Callback(() => completionSource.TrySetResult(true));
249+
.Callback(() => completionSource.TrySetResult(true))
250+
.Returns(mockConsumer.Object);
246251

247252
var partitionProcessor = mockProcessor.Object.CreatePartitionProcessor(new EventProcessorPartition(), cancellationSource, EventPosition.Earliest);
248253

0 commit comments

Comments
 (0)