Ejemplo n.º 1
0
        public void CanInitConfigModuleEnumerator()
        {
            MockConfigurationStore store      = new MockConfigurationStore();
            IModuleEnumerator      enumerator = new ConfigurationModuleEnumerator(store);

            Assert.IsNotNull(enumerator);
        }
        public void EnumeratesThreeModulesWithDependencies()
        {
            var store   = new MockConfigurationStore();
            var module1 = new ModuleConfigurationElement("Module1.dll", "Test.Module1", "Module1", false)
            {
                Dependencies = new ModuleDependencyCollection(
                    new[] { new ModuleDependencyConfigurationElement("Module2") })
            };

            var module2 = new ModuleConfigurationElement("Module2.dll", "Test.Module2", "Module2", false)
            {
                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.Equal(3, modules.Count());
            Assert.Contains(modules, module => module.ModuleName == "Module1");
            Assert.Contains(modules, module => module.ModuleName == "Module2");
            Assert.Contains(modules, module => module.ModuleName == "Module3");
        }
Ejemplo n.º 3
0
        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 ShouldReturnAListOfModuleInfo()
        {
            MockConfigurationStore store = new MockConfigurationStore
            {
                Modules = new[] { new ModuleConfigurationElement(@"MocksModules\MockModuleA.dll", "TestModules.MockModuleAClass", "MockModuleA", false) }
            };

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

            catalog.Load();

            var modules = catalog.Modules;

            Assert.NotNull(modules);
            Assert.Single(modules);
            Assert.NotEqual(InitializationMode.WhenAvailable, modules.First().InitializationMode);
            Assert.NotNull(modules.First().Ref);
            Assert.StartsWith("file://", modules.First().Ref);
            Assert.Contains(@"MocksModules/MockModuleA.dll", modules.First().Ref);
            Assert.NotNull(modules.First().ModuleType);
            Assert.Equal("TestModules.MockModuleAClass", modules.First().ModuleType);
        }
Ejemplo n.º 5
0
        public void CanInitConfigModuleEnumerator()
        {
            MockConfigurationStore     store   = new MockConfigurationStore();
            ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog();

            catalog.Store = store;
            Assert.IsNotNull(catalog);
        }
Ejemplo n.º 6
0
        public void GetZeroModules()
        {
            MockConfigurationStore store      = new MockConfigurationStore();
            IModuleEnumerator      enumerator = new ConfigurationModuleEnumerator(store);

            ModuleInfo[] modules = enumerator.GetModules();

            Assert.AreEqual(0, modules.Length);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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();
        }
        public void GetZeroModules()
        {
            MockConfigurationStore     store   = new MockConfigurationStore();
            ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog()
            {
                Store = store
            };

            catalog.Load();

            Assert.Empty(catalog.Modules);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public void GetZeroModules()
        {
            MockConfigurationStore     store   = new MockConfigurationStore();
            ConfigurationModuleCatalog catalog = new ConfigurationModuleCatalog()
            {
                Store = store
            };

            catalog.Load();

            Assert.AreEqual(0, catalog.Modules.Count());
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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 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.Equal(2, catalog.Modules.Count());
        }
        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.Single(catalog.Modules);
            Assert.Equal <int>(0, catalog.Modules.Count(m => m.InitializationMode != InitializationMode.OnDemand));
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        public void ShouldReturnAListOfModuleInfo()
        {
            MockConfigurationStore store = new MockConfigurationStore();

            store.Modules = new[] { new ModuleConfigurationElement(@"MocksModules\MockModuleA.dll", "TestModules.MockModuleAClass", "MockModuleA", false) };

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

            catalog.Load();

            IEnumerable <ModuleInfo> modules = catalog.Modules;

            Assert.IsNotNull(modules);
            Assert.AreEqual(1, modules.Count());
            Assert.AreNotEqual(InitializationMode.WhenAvailable, modules.First().InitializationMode);
            Assert.IsNotNull(modules.First().Ref);
            StringAssert.StartsWith(modules.First().Ref, "file://");
            Assert.IsTrue(modules.First().Ref.Contains(@"MocksModules/MockModuleA.dll"));
            Assert.IsNotNull(modules.First().ModuleType);
            Assert.AreEqual("TestModules.MockModuleAClass", modules.First().ModuleType);
        }