diff --git a/src/ContainerScopedProjectionTests/projections_with_IoC_services.cs b/src/ContainerScopedProjectionTests/projections_with_IoC_services.cs index 5864ea584c..908d26222d 100644 --- a/src/ContainerScopedProjectionTests/projections_with_IoC_services.cs +++ b/src/ContainerScopedProjectionTests/projections_with_IoC_services.cs @@ -19,12 +19,20 @@ using Shouldly; using Weasel.Postgresql; using Xunit; +using Xunit.Abstractions; namespace ContainerScopedProjectionTests; [Collection("ioc")] public class projections_with_IoC_services { + private readonly ITestOutputHelper _output; + + public projections_with_IoC_services(ITestOutputHelper output) + { + _output = output; + } + [Fact] public async Task can_apply_database_changes_at_runtime_with_projection_with_services() { @@ -366,7 +374,7 @@ public async Task get_async_shards_with_custom_name_on_martenStore() [Fact] public async Task use_multistream_projection_as_scoped_and_inline_on_martenStore() { - using var host = await Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() + using var host = await Host.CreateDefaultBuilder() .ConfigureServices(services => { services.AddSingleton(); @@ -393,7 +401,47 @@ public async Task use_multistream_projection_as_scoped_and_inline_on_martenStore product.Name.ShouldBe("Ankle Socks"); // Now rebuild - var daemon = await store.BuildProjectionDaemonAsync(); + var daemon = await store.BuildProjectionDaemonAsync(logger:new TestOutputMartenLogger(_output)); + await daemon.RebuildProjectionAsync(CancellationToken.None); + + // Test again + product = await session.LoadAsync(streamId); + product.Price.ShouldBeGreaterThan(0); + product.Name.ShouldBe("Ankle Socks"); + } + + + [Fact] + public async Task use_multistream_projection_as_singleton_and_inline_on_martenStore() + { + using var host = await Host.CreateDefaultBuilder() + .ConfigureServices(services => + { + services.AddSingleton(); + + services.AddMartenStore(opts => + { + opts.Connection(ConnectionSource.ConnectionString); + opts.DatabaseSchemaName = "ioc3"; + opts.ApplyChangesLockId = opts.ApplyChangesLockId + 9; + }).AddProjectionWithServices(ProjectionLifecycle.Inline, ServiceLifetime.Singleton, "MyProjection") + .ApplyAllDatabaseChangesOnStartup(); + }).StartAsync(); + + var store = host.Services.GetRequiredService(); + + + + await using var session = store.LightweightSession(); + var streamId = session.Events.StartStream(new ProductRegistered("Ankle Socks", "Socks")).Id; + await session.SaveChangesAsync(); + + var product = await session.LoadAsync(streamId); + product.Price.ShouldBeGreaterThan(0); + product.Name.ShouldBe("Ankle Socks"); + + // Now rebuild + var daemon = await store.BuildProjectionDaemonAsync(logger:new TestOutputMartenLogger(_output)); await daemon.RebuildProjectionAsync(CancellationToken.None); // Test again diff --git a/src/DaemonTests/Internals/HighWaterAgentTests.cs b/src/DaemonTests/Internals/HighWaterAgentTests.cs index c76ee53ed8..38f058618c 100644 --- a/src/DaemonTests/Internals/HighWaterAgentTests.cs +++ b/src/DaemonTests/Internals/HighWaterAgentTests.cs @@ -110,11 +110,11 @@ public async Task will_not_go_in_loop_when_sequence_is_advanced_but_gaps_from_hi [Fact] public async Task skips_multiple_gaps_and_keeps_advancing() { - NumberOfStreams = 10; + NumberOfStreams = 100; await PublishSingleThreaded(); // Create multiple gaps in the event sequence - var gaps = new[] { NumberOfEvents - 9, NumberOfEvents - 6, NumberOfEvents - 5, NumberOfEvents - 3 }; + var gaps = new[] { NumberOfEvents - 50,NumberOfEvents - 9, NumberOfEvents - 6, NumberOfEvents - 5, NumberOfEvents - 3 }; await deleteEvents(gaps); // Make gap skipping kick in faster @@ -127,6 +127,7 @@ public async Task skips_multiple_gaps_and_keeps_advancing() await agent.Tracker.WaitForHighWaterMark(gaps[1], 2.Seconds()); await agent.Tracker.WaitForHighWaterMark(gaps[2], 2.Seconds()); await agent.Tracker.WaitForHighWaterMark(gaps[3], 2.Seconds()); + await agent.Tracker.WaitForHighWaterMark(gaps[4], 2.Seconds()); // And eventually reach the head await agent.Tracker.WaitForHighWaterMark(NumberOfEvents, 2.Seconds()); diff --git a/src/Marten/Marten.csproj b/src/Marten/Marten.csproj index 8d731b5bf0..455de1556c 100644 --- a/src/Marten/Marten.csproj +++ b/src/Marten/Marten.csproj @@ -33,9 +33,9 @@ - - - + + + @@ -43,11 +43,5 @@ - - - - - -