public void GetZeroModules()
        {
            MockConfigurationStore store = new MockConfigurationStore();
            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);

            ModuleInfo[] modules = enumerator.GetModules();

            Assert.AreEqual(0, modules.Length);
        }
        public void ShouldReturnAListOfModuleInfo()
        {
            MockConfigurationStore store = new MockConfigurationStore();
            store.Modules = new[] { new ModuleConfigurationElement(@"MocksModules\MockModuleA.dll", "Microsoft.Composite.Tests.Mocks.Modules.MockModuleA", "MockModuleA", false) };

            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);

            ModuleInfo[] modules = enumerator.GetModules();

            Assert.IsNotNull(modules);
            Assert.AreEqual(1, modules.Length);
            Assert.IsNotNull(modules[0].AssemblyFile);
            Assert.IsTrue(modules[0].AssemblyFile.Contains(@"MocksModules\MockModuleA.dll"));
            Assert.IsNotNull(modules[0].ModuleType);
            Assert.AreEqual("Microsoft.Composite.Tests.Mocks.Modules.MockModuleA", modules[0].ModuleType);
            Assert.IsFalse(modules[0].StartupLoaded);
        }
        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 };

            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);

            var modules = new List<ModuleInfo>(enumerator.GetModules());

            Assert.AreEqual(3, modules.Count);
            Assert.IsTrue(modules.Exists(module => module.ModuleName == "Module1"));
            Assert.IsTrue(modules.Exists(module => module.ModuleName == "Module2"));
            Assert.IsTrue(modules.Exists(module => module.ModuleName == "Module3"));
        }
 public void CanInitWithDefaultConstructor()
 {
     IModuleEnumerator enumerator = new ConfigurationModuleEnumerator();
     Assert.IsNotNull(enumerator);
 }
 public void CanInitConfigModuleEnumerator()
 {
     MockConfigurationStore store = new MockConfigurationStore();
     IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);
     Assert.IsNotNull(enumerator);
 }
 public void NullConfigurationStoreThrows()
 {
     IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(null);
 }
        public void GetModulesNotThrownIfModuleSectionIsNotDeclared()
        {
            MockNullConfigurationStore store = new MockNullConfigurationStore();

            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);

            var modules = enumerator.GetModules();

            Assert.IsNotNull(modules);
            Assert.AreEqual(0, modules.Length);
        }
        public void GetModuleReturnsOnlySpecifiedModule()
        {
            MockConfigurationStore store = new MockConfigurationStore();
            var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false);

            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);
            store.Modules = new[] { module1 };

            var module = enumerator.GetModule("Module1");

            Assert.IsNotNull(module);
            Assert.AreEqual("Module1", module.ModuleName);
        }
        public void GetStartupLoadedModulesDoesntRetrieveOnDemandLoaded()
        {
            MockConfigurationStore store = new MockConfigurationStore();
            var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false);

            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);
            store.Modules = new[] { module1 };

            Assert.AreEqual<int>(1, enumerator.GetModules().Length);
            Assert.AreEqual<int>(0, enumerator.GetStartupLoadedModules().Length);
        }
        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 };
            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);

            Assert.AreEqual(2, enumerator.GetModules().Length);
        }
        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 };
            IModuleEnumerator enumerator = new ConfigurationModuleEnumerator(store);

            ModuleInfo[] modules = enumerator.GetModules();
        }