public async Task If_events_have_been_processed_after_initial_replay_then_the_remaining_time_is_estimated_correctly() { //arrange //Initial replay Events.Write(10); var projector = new TestProjector(); await RunCatchup(projector); //new set of events come in IEnumerable <EventHandlerProgress> progress = null; Events.Write(10); var eventsProcessed = 0; projector.DoSomething = e => { if (eventsProcessed == 5) { progress = EventHandlerProgressCalculator.Calculate(() => ReadModelDbContext()); } VirtualClock.Current.AdvanceBy(TimeSpan.FromSeconds(1)); eventsProcessed++; }; //act await RunCatchup(projector); progress.First(p => p.Name == EventHandler.FullName(projector)) .TimeRemainingForCatchup.Value .Should() .Be(TimeSpan.FromSeconds(5)); }
public async Task If_events_have_been_processed_then_the_correct_number_of_remaining_events_is_returned() { //arrange IEnumerable <EventHandlerProgress> progress = null; Events.Write(5); var eventsProcessed = 0; var projector = new TestProjector { DoSomething = e => { if (eventsProcessed == 4) { progress = EventHandlerProgressCalculator.Calculate(() => ReadModelDbContext()); } eventsProcessed++; } }; //act await RunCatchup(projector); //assert progress.First(p => p.Name == EventHandler.FullName(projector)) .EventsRemaining .Should() .Be(1); }
public async Task If_events_have_been_processed_after_initial_replay_then_the_number_of_events_for_initial_replay_is_saved() { //arrange ResetReadModelInfo(); var projector = new TestProjector { DoSomething = e => VirtualClock.Current.AdvanceBy(TimeSpan.FromSeconds(1)) }; //Initial replay Events.Write(10); await RunCatchup(projector); //new set of events come in Events.Write(5); await RunCatchup(projector); //act var progress = EventHandlerProgressCalculator.Calculate(() => ReadModelDbContext()); //assert progress.First(p => p.Name == EventHandler.FullName(projector)) .InitialCatchupEvents.Value .Should() .Be(10); }
public async Task If_no_events_have_been_processed_then_the_remaining_time_is_null() { //arrange ResetReadModelInfo(); Events.Write(5); //act var progress = EventHandlerProgressCalculator.Calculate(() => ReadModelDbContext()); //assert progress.First(p => p.Name == EventHandler.FullName(new TestProjector())) .TimeRemainingForCatchup .HasValue .Should() .BeFalse(); }
public async Task If_all_events_have_been_processed_then_the_percentage_completed_is_100() { //arrange Events.Write(5); var projector = new TestProjector(); await RunCatchup(projector); //act var progress = EventHandlerProgressCalculator.Calculate(() => ReadModelDbContext()); //assert progress.First(p => p.Name == EventHandler.FullName(projector)) .PercentageCompleted .Should() .Be(100); }
public async Task If_all_events_have_been_processed_then_the_remaining_time_is_zero() { //arrange var projector = new TestProjector(); Events.Write(5); await RunCatchup(projector); //act var progress = EventHandlerProgressCalculator.Calculate(() => ReadModelDbContext()); //assert progress.First(p => p.Name == EventHandler.FullName(projector)) .TimeRemainingForCatchup .Value .Should() .Be(TimeSpan.FromMinutes(0)); }