diff --git a/src/EventSourcingTests/Projections/using_explicit_code_for_live_aggregation.cs b/src/EventSourcingTests/Projections/using_explicit_code_for_live_aggregation.cs index bd28df48cb..d0dccb009c 100644 --- a/src/EventSourcingTests/Projections/using_explicit_code_for_live_aggregation.cs +++ b/src/EventSourcingTests/Projections/using_explicit_code_for_live_aggregation.cs @@ -9,6 +9,7 @@ using Marten.Events.Projections; using Marten.Testing.Harness; using Shouldly; +using Weasel.Postgresql.Tables; using Xunit; namespace EventSourcingTests.Projections; @@ -28,8 +29,6 @@ public async Task using_a_custom_projection_for_live_aggregation() await theSession.SaveChangesAsync(); var aggregate = await theSession.Events.AggregateStreamAsync(streamId); - theStore.StorageFeatures.AllDocumentMappings.Select(x => x.DocumentType) - .ShouldNotContain(typeof(SimpleAggregate)); aggregate.ACount.ShouldBe(2); aggregate.BCount.ShouldBe(1); aggregate.CCount.ShouldBe(3); @@ -48,7 +47,7 @@ public async Task using_a_custom_projection_for_live_aggregation_with_query_sess var streamId = theSession.Events.StartStream(new AEvent(), new AEvent(), new BEvent(), new CEvent(), new CEvent(), new CEvent()).Id; await theSession.SaveChangesAsync(); - using var query = theStore.QuerySession(); + await using var query = theStore.QuerySession(); var aggregate = await query.Events.AggregateStreamAsync(streamId); aggregate.ACount.ShouldBe(2); @@ -56,6 +55,24 @@ public async Task using_a_custom_projection_for_live_aggregation_with_query_sess aggregate.CCount.ShouldBe(3); aggregate.Id.ShouldBe(streamId); } + + [Fact] + public async Task does_not_create_tables() + { + StoreOptions(opts => + { + opts.Projections.Add(new ExplicitCounter(), ProjectionLifecycle.Live); + }); + + var streamId = theSession.Events.StartStream(new AEvent(), new AEvent(), new BEvent(), new CEvent(), new CEvent(), new CEvent()).Id; + await theSession.SaveChangesAsync(); + await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); + + var eventStream = await theSession.Events.FetchForWriting(streamId); + await theSession.SaveChangesAsync(); + var tables = theStore.Storage.AllObjects().OfType(); + tables.ShouldNotContain(x => x.Identifier.Name.Contains(nameof(SimpleAggregate), StringComparison.OrdinalIgnoreCase)); + } } #region sample_using_simple_explicit_code_for_live_aggregation