public void GetFlushActions_ReturnsExpectedFlushActions() { //prepare Dictionary <Type, EntityContext> entityContexts = GetEntityContexts(new Dictionary <Type, long> { { typeof(Category), 100 }, { typeof(Post), 100 }, { typeof(Comment), 98 }, }, 100); CompleteFlushCandidatesRegistry target = SetupCompleteFlushCandidatesRegistry(entityContexts); //simulate that Comment generation is finished entityContexts[typeof(Comment)].EntityProgress.CurrentCount = 100; //invoke EntityContext entityContext = entityContexts[typeof(Comment)]; List <ICommand> flushCommands = target.GetNextFlushCommands(entityContext); //assert flushCommands.Should().AllBeOfType <FlushCommand>(); var actualFlushActions = flushCommands .Select(x => ((FlushCommand)x).EntityContext.Description.Type); var expectedActions = new Type[] { typeof(Comment), typeof(Post), typeof(Category) }; actualFlushActions.Should().BeEquivalentTo(expectedActions); }
private CompleteFlushCandidatesRegistry SetupCompleteFlushCandidatesRegistry( Dictionary <Type, EntityContext> contexts) { var generatorSetup = new GeneratorSetup(); var progressState = new CompleteProgressState(contexts); var target = new CompleteFlushCandidatesRegistry(generatorSetup, contexts, progressState); //Add flush candidates target.CheckIsFlushRequired(contexts[typeof(Post)]); target.CheckIsFlushRequired(contexts[typeof(Category)]); target.CheckIsFlushRequired(contexts[typeof(Comment)]); return(target); }