-
Notifications
You must be signed in to change notification settings - Fork 492
Expand file tree
/
Copy pathInMemoryEventBusTests.cs
More file actions
33 lines (27 loc) · 1.1 KB
/
InMemoryEventBusTests.cs
File metadata and controls
33 lines (27 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace EvolutionaryArchitecture.Fitnet.IntegrationTests.Common.Events.EventBus.InMemory;
using Fitnet.Common.Events.EventBus;
using TestEngine.Configuration;
public sealed class InMemoryEventBusTests(
WebApplicationFactory<Program> applicationInMemoryFactory,
DatabaseContainer database) : IClassFixture<WebApplicationFactory<Program>>, IClassFixture<DatabaseContainer>
{
private readonly WebApplicationFactory<Program> _applicationInMemory = applicationInMemoryFactory
.WithContainerDatabaseConfigured(database.ConnectionString!)
.WithFakeConsumers();
[Fact]
internal async Task Given_valid_event_published_Then_event_should_be_consumed()
{
// Arrange
var eventBus = GetEventBus();
var fakeEvent = FakeEvent.Create();
// Act
await eventBus!.PublishAsync(fakeEvent, CancellationToken.None);
// Assert
fakeEvent.Consumed.ShouldBeTrue();
}
private IEventBus GetEventBus() =>
_applicationInMemory.Services
.CreateScope()!
.ServiceProvider
.GetRequiredService<IEventBus>();
}