Skip to content

Commit

Permalink
Move local function out to private method
Browse files Browse the repository at this point in the history
  • Loading branch information
Waddas committed Jul 30, 2024
1 parent b1b6dcd commit 130775a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/KafkaFlow.IntegrationTests/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public async Task ManualAssignPartitionOffsetsTest()
.Without(m => m.Offset)
.CreateMany(10).ToList();

messages.ForEach(m => producer.Produce(m.Id.ToString(), m, null, DeliveryHandler));
messages.ForEach(m => producer.Produce(m.Id.ToString(), m, null, report => DeliveryHandler(report, messages)));

foreach (var message in messages)
{
Expand Down Expand Up @@ -211,14 +211,12 @@ await serviceProviderHelper.GetServiceProviderAsync(
}

await serviceProviderHelper.StopBusAsync();

return;

void DeliveryHandler(DeliveryReport<byte[], byte[]> report)
{
var key = Encoding.UTF8.GetString(report.Message.Key);
var message = messages.First(m => m.Id.ToString() == key);
message.Offset = report.Offset;
}
}

private static void DeliveryHandler(DeliveryReport<byte[], byte[]> report, List<OffsetTrackerMessage> messages)
{
var key = Encoding.UTF8.GetString(report.Message.Key);
var message = messages.First(m => m.Id.ToString() == key);
message.Offset = report.Offset;
}
}

0 comments on commit 130775a

Please sign in to comment.