public void TestName()
        {
            DependantModuleInfo info = new DependantModuleInfo("Module1", "Module1.Implementation", "~/Module1");
            info.Dependencies = new ModuleDependency[] {new ModuleDependency()};
            info.Dependencies[0].Name = "Module0";
            StringWriter sw = new StringWriter();
            XmlSerializer xser = new XmlSerializer(typeof (DependantModuleInfo));

            xser.Serialize(sw, info);
            Console.Write(sw.GetStringBuilder().ToString());
        }
        public void TranslateDependantModuleInfo()
        {
            DependantModuleInfo dependantModuleInfo = new DependantModuleInfo("Module1", "Module1.dll", "Module1");
            dependantModuleInfo.Dependencies = new ModuleDependency[1];

            ModuleDependency dependency = new ModuleDependency();
            dependency.Name = "ModuleDependency";

            dependantModuleInfo.Dependencies[0] = dependency;

            DependantModuleInfo[] modules = new DependantModuleInfo[1];
            modules[0] = dependantModuleInfo;

            GuidancePackageModuleInfo[] guidanceModules = new ModuleInfoMapper().Translate(modules);

            Assert.AreEqual(guidanceModules.Length, modules.Length);
            Assert.AreEqual(guidanceModules[0].Name, dependantModuleInfo.Name);
            Assert.AreEqual(guidanceModules[0].AssemblyName, dependantModuleInfo.AssemblyName);
            Assert.AreEqual(guidanceModules[0].VirtualPath, dependantModuleInfo.VirtualPath);
            Assert.AreEqual(guidanceModules[0].Dependencies.Length, dependantModuleInfo.Dependencies.Length);
            Assert.AreEqual(guidanceModules[0].Dependencies[0].Name, dependantModuleInfo.Dependencies[0].Name);
        }
        /// <summary>
        /// Gets the list of modules needed by the application.
        /// </summary>
        /// <returns>An array of <see cref="IModuleInfo"/>.</returns>
        public IModuleInfo[] EnumerateModules()
        {
            if (_modules != null) return _modules;

            List<DependantModuleInfo> moduleInfos = new List<DependantModuleInfo>();
            ModulesConfigurationSection section = _store.GetModuleConfigurationSection();
            ValidateDuplicates(section);

            foreach (ModuleConfigurationElement data in section.Modules)
            {
                DependantModuleInfo moduleInfo = new DependantModuleInfo(data.Name, data.AssemblyName, data.VirtualPath);
                if (data.Dependencies.Count > 0)
                {
                    moduleInfo.Dependencies = new ModuleDependency[data.Dependencies.Count];
                    for (int i = 0; i < data.Dependencies.Count; i++)
                    {
                        moduleInfo.Dependencies[i] = new ModuleDependency();
                        moduleInfo.Dependencies[i].Name = data.Dependencies[i].Module;
                    }
                }

                if (data.Services.Count > 0)
                {
                    moduleInfo.Services = new ServiceInfo[data.Services.Count];

                    for (int i = 0; i < data.Services.Count; i++)
                    {
                        moduleInfo.Services[i] =
                            new ServiceInfo(data.Services[i].RegisterAs, data.Services[i].Type, data.Services[i].Scope);
                    }
                }

                moduleInfos.Add(moduleInfo);
            }

            if (moduleInfos.Count > 0)
            {
                _modules = SortModules(moduleInfos);
            }
            else
            {
                _modules = moduleInfos.ToArray();
            }
            return _modules;
        }
 private List<IProjectModel> FilterProjectsWithVirtualPathNotNullAndContainedInCurrentWebsite(List<IProjectModel> moduleProjects, DependantModuleInfo[] moduleInfos, IList<IProjectItemModel> webFolders)
 {
     List<IProjectModel> filtered = new List<IProjectModel>();
     foreach (IProjectModel project in moduleProjects)
     {
         IModuleInfo projectModuleInfo = FindModuleInfo(project.AssemblyName, moduleInfos);
         if (projectModuleInfo != null)
         {
             if (!string.IsNullOrEmpty(projectModuleInfo.VirtualPath))
             {
                 if ((projectModuleInfo.AssemblyName == this.ModuleProject.AssemblyName)
                 || WebFolderExistsInWebsite(projectModuleInfo.VirtualPath, webFolders))
                     filtered.Add(project);
             }
         }
     }
     return filtered;
 }
        public void TestDependantModuleInfoIsIModuleInfo()
        {
            DependantModuleInfo info = new DependantModuleInfo("name", "type", "location");

            Assert.IsTrue(info is IModuleInfo);
        }
        public void CanCreateDependantModule()
        {
            DependantModuleInfo info = new DependantModuleInfo();

            Assert.IsNotNull(info is IModuleInfo);
        }
        public void LoadRegistersServicesUsingIServiceLoaderService()
        {
            CompositionContainer mockContainer = new TestableRootCompositionContainer();
            MockServiceLoaderService serviceLoaderService = new MockServiceLoaderService();
            mockContainer.Services.Add<IServiceLoaderService>(serviceLoaderService);
            ModuleLoaderService loader = new ModuleLoaderService();
            DependantModuleInfo moduleInfo =
                new DependantModuleInfo("TestModule", generatedAssemblies["TestModule"].FullName, "~/TestModule");
            moduleInfo.Services =
                new ServiceInfo[1] {new ServiceInfo(typeof (IMockService), typeof (MockService), ServiceScope.Global)};

            loader.Load(mockContainer, moduleInfo);

            Assert.IsNotNull(serviceLoaderService.UsedServices);
            Assert.AreEqual(1, serviceLoaderService.UsedServices.Length);
            Assert.AreEqual(typeof (IMockService), serviceLoaderService.UsedServices[0].RegisterAs);
            Assert.IsNotNull(serviceLoaderService.UsedCompositionContainer);
            Assert.AreEqual(mockContainer.Containers["TestModule"], serviceLoaderService.UsedCompositionContainer);
        }