Skip to content

Commit

Permalink
Merge pull request #611 from mbican/EF-605_ProcessSagaAsync_SourceId
Browse files Browse the repository at this point in the history
EF-605: use EventId as SourceId for external event delivered to saga …
  • Loading branch information
rasmus authored Apr 11, 2019
2 parents d2f528a + 9f6d3fa commit 367dc0f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- `EventFlow.Sql`
- `EventFlow.SQLite`
* New: Added [SourceLink](https://github.com/dotnet/sourcelink) support
* Fix: `DispatchToSagas.ProcessSagaAsync` use `EventId` instead of `SourceId` as `SourceId`
for delivery of external event to AggregateSaga
* Fix: `Identity<T>.NewComb()` now produces string values that doesn't cause
too much index fragmentation in MSSQL string columns

Expand Down
1 change: 1 addition & 0 deletions Source/EventFlow.TestHelpers/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ protected IDomainEvent<ThingyAggregate, ThingyId> ToDomainEvent<TAggregateEvent>
{
Timestamp = A<DateTimeOffset>(),
SourceId = A<SourceId>(),
EventId = A<EventId>(),
};

if (aggregateSequenceNumber == 0)
Expand Down
17 changes: 17 additions & 0 deletions Source/EventFlow.Tests/UnitTests/Sagas/DispatchToSagasTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ public async Task SagaUpdaterIsInvokedCorrectly()
Times.Exactly(domainEventCount));
}

[Test]
public async Task SagaStoreReceivesEventIdAsSourceId()
{
// Arrange
var sagaMock = Arrange_Woking_SagaStore(SagaState.Running);
var domainEvent = ADomainEvent<ThingyPingEvent>();

// Act
await Sut.ProcessAsync(new[] { domainEvent }, CancellationToken.None).ConfigureAwait(false);

// Assert
_sagaStoreMock.Verify(a => a.UpdateAsync(It.IsAny<ISagaId>(), It.IsAny<Type>(),
domainEvent.Metadata.EventId,
It.IsAny<Func<ISaga, CancellationToken, Task>>(),
It.IsAny<CancellationToken>()));
}

[Test]
public async Task SagaErrorHandlerIsInvokedCorrectly()
{
Expand Down
2 changes: 1 addition & 1 deletion Source/EventFlow/Sagas/DispatchToSagas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private async Task ProcessSagaAsync(
await _sagaStore.UpdateAsync(
sagaId,
details.SagaType,
domainEvent.Metadata.SourceId,
domainEvent.Metadata.EventId,
(s, c) => UpdateSagaAsync(s, domainEvent, details, c),
cancellationToken)
.ConfigureAwait(false);
Expand Down

0 comments on commit 367dc0f

Please sign in to comment.