Exemplo n.º 1
0
        //Setup helpers
        private CompleteSupervisor SetupCompleteOrderProvider(
            List <IEntityDescription> descriptions)
        {
            var generatorSetup = new GeneratorSetup();
            Dictionary <Type, IEntityDescription> dictDescriptions =
                descriptions.ToDictionary(x => x.Type, x => x);
            Dictionary <Type, EntityContext> contexts =
                generatorSetup.SetupEntityContexts(dictDescriptions);

            var target = new CompleteSupervisor();

            target.Setup(generatorSetup, contexts);
            return(target);
        }
Exemplo n.º 2
0
        //Setup helpers
        private Dictionary <Type, EntityContext> GetEntityContexts(
            Dictionary <Type, long> entityCurrentCount, long targetCount)
        {
            var generatorSetup = new GeneratorSetup();

            var category = new EntityDescription <Category>()
                           .SetTargetCount(targetCount);
            var post = new EntityDescription <Post>()
                       .SetTargetCount(targetCount)
                       .SetRequired(typeof(Category));
            var comment = new EntityDescription <Comment>()
                          .SetTargetCount(targetCount)
                          .SetRequired(typeof(Post))
                          .SetRequired(typeof(Category));
            Dictionary <Type, IEntityDescription> dictDescriptions = new List <IEntityDescription>
            {
                category,
                post,
                comment
            }.ToDictionary(x => x.Type, x => x);

            Dictionary <Type, EntityContext> contexts =
                generatorSetup.SetupEntityContexts(dictDescriptions);

            contexts.Values.ToList().ForEach(x =>
            {
                x.EntityProgress.AddFlushedCount(0);
                x.EntityProgress.NextFlushCount = 0;
            });

            foreach (KeyValuePair <Type, long> entity in entityCurrentCount)
            {
                contexts[entity.Key].EntityProgress.CurrentCount = entity.Value;
            }

            return(contexts);
        }