Esempio n. 1
0
        public void WeighterTests_2Levels()
        {
            var modules = new List <Type> {
                typeof(Module2), typeof(Module1), typeof(Module3)
            };
            var weighter       = new ModuleWeighter();
            var modulesWithDep =
                modules.Select(
                    m =>
                    new ModuleDescriptor(this._container.GetInstance(m) as IInitializableModule,
                                         m,
                                         TypeHelper.GetAttributes <ModuleDependencyAttribute>(m).Select(d => d.DependencyModule))).ToList();

            var executableModules = weighter.SortModules(modulesWithDep).ToList();

            Assert.Equal(2, executableModules.Single(md => md.ModuleType == typeof(Module1)).Weight);
            Assert.Equal(1, executableModules.Single(md => md.ModuleType == typeof(Module2)).Weight);
        }
        public void ModuleExecutionTests()
        {
            var modules = new List<Type> { typeof(Module2), typeof(Module1), typeof(Module5), typeof(Module3), typeof(Module4) };

            var modulesWithDep =
                modules.Select(
                               m =>
                               new ModuleDescriptor(this._container.GetInstance(m) as IInitializableModule,
                                                    m,
                                                    TypeHelper.GetAttributes<ModuleDependencyAttribute>(m).Select(d => d.DependencyModule))).ToList();

            Assert.NotNull(modulesWithDep);

            var engine = new ModuleExecutionEngine();
            var weighter = new ModuleWeighter();

            var context = engine.RunModules(weighter.SortModules(modulesWithDep), new ModuleExecutionContext());
            Assert.NotEmpty(context.Log);
        }
Esempio n. 3
0
        public void ModuleExecutionTests()
        {
            var modules = new List <Type> {
                typeof(Module2), typeof(Module1), typeof(Module5), typeof(Module3), typeof(Module4)
            };

            var modulesWithDep =
                modules.Select(
                    m =>
                    new ModuleDescriptor(this._container.GetInstance(m) as IInitializableModule,
                                         m,
                                         TypeHelper.GetAttributes <ModuleDependencyAttribute>(m).Select(d => d.DependencyModule))).ToList();

            Assert.NotNull(modulesWithDep);

            var engine   = new ModuleExecutionEngine();
            var weighter = new ModuleWeighter();

            var context = engine.RunModules(weighter.SortModules(modulesWithDep), new ModuleExecutionContext());

            Assert.NotEmpty(context.Log);
        }
        public void WeighterTests_2Levels()
        {
            var modules = new List<Type> { typeof(Module2), typeof(Module1), typeof(Module3) };
            var weighter = new ModuleWeighter();
            var modulesWithDep =
                modules.Select(
                               m =>
                               new ModuleDescriptor(this._container.GetInstance(m) as IInitializableModule,
                                                    m,
                                                    TypeHelper.GetAttributes<ModuleDependencyAttribute>(m).Select(d => d.DependencyModule))).ToList();

            var executableModules = weighter.SortModules(modulesWithDep).ToList();

            Assert.Equal(2, executableModules.Single(md => md.ModuleType == typeof(Module1)).Weight);
            Assert.Equal(1, executableModules.Single(md => md.ModuleType == typeof(Module2)).Weight);
        }