Skip to content

Commit

Permalink
Fixed wrong entity definition conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Sep 5, 2024
1 parent 7418ff0 commit 72ef869
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public async ValueTask Publish(object[] events, CancellationToken ct)
{
foreach (var @event in events)
{
if (!eventHandlers.TryGetValue(@event.GetType(), out var handlers))
continue;

foreach (var middleware in middlewares)
middleware(@event);

if (!eventHandlers.TryGetValue(@event.GetType(), out var handlers))
continue;

foreach (var handler in handlers)
await handler(@event, ct);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public void Catch(object message) =>
public void ShouldNotReceiveAnyMessage() =>
Published.Should().BeEmpty();


public void ShouldReceiveMessage<T>(T message) where T: notnull
{
Published.Should().Contain(message);
}

public void ShouldReceiveSingleMessage<T>(T message)
{
Published.Should().HaveCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public async Task GroupCheckoutForMultipleGuestStay_ShouldBeInitiated()
await guestStayFacade.InitiateGroupCheckout(command);

// Then
publishedMessages.ShouldReceiveSingleMessage(new GroupCheckoutEvent.GroupCheckoutInitiated(groupCheckoutId, clerkId, guestStays, now));
publishedMessages.ShouldReceiveMessage(new GroupCheckoutEvent.GroupCheckoutInitiated(groupCheckoutId, clerkId, guestStays, now));
}

private readonly Database database = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public async Task CheckingOutGuestWithSettledBalance_FailsWithGuestCheckoutFaile
}

// Then
publishedMessages.ShouldReceiveSingleMessage(new GuestCheckOutFailed(guestStayId, GuestCheckOutFailed.FailureReason.BalanceNotSettled, now));
publishedMessages.ShouldReceiveMessage(new GuestCheckOutFailed(guestStayId, GuestCheckOutFailed.FailureReason.BalanceNotSettled, now));
}

private readonly Database database = new();
Expand Down

0 comments on commit 72ef869

Please sign in to comment.