public async Task PublishingStartAndCompleteWithPingsResultInCorrectMessages() { // Arrange var thingyId = A <ThingyId>(); // Act var pingsWithNewSaga = await PublishPingCommandsAsync(thingyId, 3).ConfigureAwait(false); await CommandBus.PublishAsync(new ThingyRequestSagaStartCommand(thingyId), CancellationToken.None).ConfigureAwait(false); var pingsWithRunningSaga = await PublishPingCommandsAsync(thingyId, 3).ConfigureAwait(false); await CommandBus.PublishAsync(new ThingyRequestSagaCompleteCommand(thingyId), CancellationToken.None).ConfigureAwait(false); var pingsWithCompletedSaga = await PublishPingCommandsAsync(thingyId, 3).ConfigureAwait(false); // Assert - saga var thingySaga = await LoadSagaAsync(thingyId).ConfigureAwait(false); thingySaga.State.Should().Be(SagaState.Completed); thingySaga.PingIdsSinceStarted.ShouldAllBeEquivalentTo(pingsWithRunningSaga); // Assert - aggregate var thingyAggregate = await LoadAggregateAsync(thingyId).ConfigureAwait(false); thingyAggregate.PingsReceived.ShouldAllBeEquivalentTo( pingsWithNewSaga.Concat(pingsWithRunningSaga).Concat(pingsWithCompletedSaga)); var receivedSagaPingIds = thingyAggregate.Messages .Select(m => PingId.With(m.Message)) .ToList(); receivedSagaPingIds.Should().HaveCount(3); receivedSagaPingIds.ShouldAllBeEquivalentTo(pingsWithRunningSaga); }
public void ValidateTestAggregate() { // Act var testAggregate = _eventStore.LoadAggregate <ThingyAggregate, ThingyId>(_thingyId, CancellationToken.None); // Assert testAggregate.Version.Should().Be(2); testAggregate.PingsReceived.Should().Contain(PingId.With("95433aa0-11f7-4128-bd5f-18e0ecc4d7c1")); testAggregate.PingsReceived.Should().Contain(PingId.With("2352d09b-4712-48cc-bb4f-5560d7c52558")); }