public ModuleConfigurationElementCollection(ModuleConfigurationElement[] modules)
 {
     if (modules == null) throw new System.ArgumentNullException("modules");
     foreach (ModuleConfigurationElement module in modules)
     {
         BaseAdd(module);
     }
 }
        public void EnumeratesThreeModulesWithDependencies()
        {
            var store = new MockConfigurationStore();
            var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false);
            module1.Dependencies = new ModuleDependencyCollection(
                new[] { new ModuleDependencyConfigurationElement("Module2") });

            var module2 = new ModuleConfigurationElement("Module2.dll", "Test.Module2", "Module2", false);
            module2.Dependencies = new ModuleDependencyCollection(
                new[] { new ModuleDependencyConfigurationElement("Module3") });

            var module3 = new ModuleConfigurationElement("Module3.dll", "Test.Module3", "Module3", false);
            store.Modules = new[] { module3, module2, module1 };

            ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog() { Store = store };
            catalog.Load();

            var modules = catalog.Modules;

            Assert.AreEqual(3, modules.Count());
            Assert.IsTrue(modules.Any(module => module.ModuleName == "Module1"));
            Assert.IsTrue(modules.Any(module => module.ModuleName == "Module2"));
            Assert.IsTrue(modules.Any(module => module.ModuleName == "Module3"));
        }
        public void GetStartupLoadedModulesDoesntRetrieveOnDemandLoaded()
        {
            MockConfigurationStore store = new MockConfigurationStore();
            var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false);
            store.Modules = new[] { module1 };

            ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog() { Store = store };
            catalog.Load();

            Assert.AreEqual<int>(1, catalog.Modules.Count());
            Assert.AreEqual<int>(0, catalog.Modules.Count(m => m.InitializationMode != InitializationMode.OnDemand));
        }
        public void EnumerateNotThrowsIfDuplicateAssemblyFile()
        {
            MockConfigurationStore store = new MockConfigurationStore();
            var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false);
            var module2 = new ModuleConfigurationElement("Module1.dll", "Test.Module2", "Module2", false);
            store.Modules = new[] { module2, module1 };
            ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog() { Store = store };
            catalog.Load();

            Assert.AreEqual(2, catalog.Modules.Count());
        }
 public void EnumerateThrowsIfDuplicateNames()
 {
     MockConfigurationStore store = new MockConfigurationStore();
     var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false);
     var module2 = new ModuleConfigurationElement("Module2.dll", "Test.Module2", "Module1", false);
     store.Modules = new[] { module2, module1 };
     ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog() { Store = store };
     catalog.Load();
 }
 /// <summary>
 /// Adds a <see cref="ModuleConfigurationElement"/> to the collection.
 /// </summary>
 /// <param name="module">A <see cref="ModuleConfigurationElement"/> instance.</param>
 public void Add(ModuleConfigurationElement module)
 {
     BaseAdd(module);
 }
 /// <summary>
 /// Adds a <see cref="ModuleConfigurationElement"/> to the collection.
 /// </summary>
 /// <param name="module">A <see cref="ModuleConfigurationElement"/> instance.</param>
 public void Add(ModuleConfigurationElement module)
 {
     BaseAdd(module);
 }