-
Notifications
You must be signed in to change notification settings - Fork 492
Expand file tree
/
Copy pathPrepareOfferTests.cs
More file actions
43 lines (35 loc) · 1.66 KB
/
PrepareOfferTests.cs
File metadata and controls
43 lines (35 loc) · 1.66 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
34
35
36
37
38
39
40
41
42
43
namespace EvolutionaryArchitecture.Fitnet.IntegrationTests.Offers.Prepare;
using Common.TestEngine.Configuration;
using Common.TestEngine.IntegrationEvents.Handlers;
using Fitnet.Offers.Prepare;
using Fitnet.Passes.MarkPassAsExpired.Events;
using EvolutionaryArchitecture.Fitnet.Common.Events.EventBus;
public sealed class PrepareOfferTests : IClassFixture<WebApplicationFactory<Program>>,
IClassFixture<DatabaseContainer>
{
private readonly WebApplicationFactory<Program> _applicationInMemory;
private readonly IEventBus _fakeEventBus = Substitute.For<IEventBus>();
public PrepareOfferTests(WebApplicationFactory<Program> applicationInMemoryFactory,
DatabaseContainer database)
{
_applicationInMemory = applicationInMemoryFactory
.WithFakeEventBus(_fakeEventBus)
.WithContainerDatabaseConfigured(database.ConnectionString!);
_applicationInMemory.CreateClient();
}
[Fact]
internal async Task Given_pass_expired_event_published_Then_new_offer_should_be_prepared()
{
// Arrange
using var integrationEventHandlerScope =
new IntegrationEventHandlerScope<PassExpiredEvent>(_applicationInMemory);
var integrationEventHandler = integrationEventHandlerScope.IntegrationEventHandler;
var @event = PassExpiredEventFaker.CreateValid();
// Act
await integrationEventHandler.Handle(@event, CancellationToken.None);
// Assert
EnsureThatOfferPreparedEventWasPublished();
}
private void EnsureThatOfferPreparedEventWasPublished() => _fakeEventBus.Received(1)
.PublishAsync(Arg.Any<OfferPrepareEvent>(), Arg.Any<CancellationToken>());
}