public async Task EventOrdering()
        {
            // Repopulating read models that span multiple aggregates should have their events
            // applied in order using events time stamps

            // Arrange
            var idA = IdA.New;
            var idB = IdB.New;
            var i   = 0;
            await CommandBus.PublishAsync(new CommandA(idA, i++), CancellationToken.None);

            await CommandBus.PublishAsync(new CommandA(idA, i++), CancellationToken.None);

            await CommandBus.PublishAsync(new CommandB(idB, i++), CancellationToken.None);

            await CommandBus.PublishAsync(new CommandB(idB, i++), CancellationToken.None);

            await ReadModelPopulator.PurgeAsync(typeof(ReadModelAB), CancellationToken.None);

            // Act
            await ReadModelPopulator.PopulateAsync(typeof(ReadModelAB), CancellationToken.None);

            // Assert
            var readModelAb = await QueryProcessor.ProcessAsync(new ReadModelByIdQuery <ReadModelAB>(ReadModeld), CancellationToken.None);

            readModelAb.Indexes.ShouldAllBeEquivalentTo(
                new [] { 0, 1, 2, 3 },
                o => o.WithStrictOrdering());
        }
        public async Task PurgeRemovesReadModels()
        {
            // Arrange
            var id = ThingyId.New;

            await PublishPingCommandAsync(id).ConfigureAwait(false);

            // Act
            await ReadModelPopulator.PurgeAsync(ReadModelType, CancellationToken.None).ConfigureAwait(false);

            var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id)).ConfigureAwait(false);

            // Assert
            readModel.Should().BeNull();
        }
        public async Task RePopulateHandlesManyAggregates()
        {
            // Arrange
            var id1 = ThingyId.New;
            var id2 = ThingyId.New;

            await PublishPingCommandsAsync(id1, 3).ConfigureAwait(false);
            await PublishPingCommandsAsync(id2, 5).ConfigureAwait(false);

            // Act
            await ReadModelPopulator.PurgeAsync(ReadModelType, CancellationToken.None).ConfigureAwait(false);

            await ReadModelPopulator.PopulateAsync(ReadModelType, CancellationToken.None).ConfigureAwait(false);

            // Assert
            var readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false);

            var readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false);

            readModel1.PingsReceived.Should().Be(3);
            readModel2.PingsReceived.Should().Be(5);
        }
예제 #4
0
 protected override Task PurgeTestAggregateReadModelAsync()
 {
     return(ReadModelPopulator.PurgeAsync <MsSqlThingyReadModel>(CancellationToken.None));
 }
예제 #5
0
 protected override Task PurgeTestAggregateReadModelAsync()
 {
     return(Task.WhenAll(
                ReadModelPopulator.PurgeAsync <InMemoryThingyReadModel>(CancellationToken.None),
                ReadModelPopulator.PurgeAsync <InMemoryThingyMessageReadModel>(CancellationToken.None)));
 }