public async Task Update_AfterCreatedWithData_PublishesUpdatedIntegrationEvent()
        {
            // Create aggregate.
            var createCommand = Fixtures.Pipelines.FakeCreateCommand();
            var createResult  = await host.SendAsync(createCommand);

            createResult.Should().BeOfType <IntegrationEventExecutionResult>();

            // Update aggregate.
            var updateCommand = Fixtures.Pipelines.FakeUpdateCommand(new CommandSeed <FakeUpdateCommand>
            {
                AggregateRootId = createCommand.AggregateRootId
            });
            var updateResult = await host.SendAsync(updateCommand);

            // Ensure is updated correctly.
            var expectedIntegrationEvent = Fixtures.IntegrationEvent <FakeUpdatedIntegrationEvent>(updateCommand, e =>
            {
                e.Data = updateCommand.Data;
            });

            updateResult.Should().BeOfType <IntegrationEventExecutionResult>()
            .Which.Event.Should().BeOfType <FakeUpdatedIntegrationEvent>()
            .Which.Should().BeEquivalentTo(expectedIntegrationEvent, options => options.ForIntegrationEvent());
        }
 public FakeDeletedIntegrationEvent FakeDeletedIntegrationEvent(FakeDeleteCommand command)
 {
     return(Fixtures.IntegrationEvent <FakeDeletedIntegrationEvent>(command, e =>
     {
         e.SnapshotId = new SnapshotId {
             EntryId = command.AggregateRootId, EntryVersion = 0
         };
     }));
 }
        public async Task Create_Always_PublishesCreatedIntegrationEvent()
        {
            var command = Fixtures.Pipelines.FakeCreateCommand();
            var result  = await host.SendAsync(command);

            var expectedIntegrationEvent = Fixtures.IntegrationEvent <FakeCreatedIntegrationEvent>(command, e =>
            {
                e.Data = command.Data;
            });

            result.Should().BeOfType <IntegrationEventExecutionResult>()
            .Which.Event.Should().BeOfType <FakeCreatedIntegrationEvent>()
            .Which.Should().BeEquivalentTo(expectedIntegrationEvent, options => options.ForIntegrationEvent());
        }
 public FakeDispatcherEvent FakeDispatcherEvent()
 {
     return(Fixtures.IntegrationEvent <FakeDispatcherEvent>(FakeDispatcherCommand(), e => { }));
 }