Skip to content

Commit

Permalink
fix: create scope in memory event bus tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilbaczek committed Aug 7, 2024
1 parent 617318c commit 1439bd9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ public sealed class InMemoryEventBusTests(
internal async Task Given_valid_event_published_Then_event_should_be_consumed()
{
// Arrange
var eventBus = ApplicationInMemory.Services.GetRequiredService<IEventBus>();
var eventBus = GetEventBus();
var fakeEvent = FakeEvent.Create();

// Act
await eventBus.PublishAsync(fakeEvent, CancellationToken.None);
await eventBus!.PublishAsync(fakeEvent, CancellationToken.None);

// Assert
fakeEvent.Consumed.Should().BeTrue();
}

private IEventBus GetEventBus() =>
ApplicationInMemory.Services
.CreateScope()
.ServiceProvider
.GetRequiredService<IEventBus>();
}

0 comments on commit 1439bd9

Please sign in to comment.