public void LoadModuleTypeShouldRaiseTheCorrespondingEvents()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            var newCatalog           = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(catalog);

            CompositionContainer container = new CompositionContainer(newCatalog);

            container.ComposeExportedValue <AggregateCatalog>(catalog);

            MefFileModuleTypeLoader loader = container.GetExportedValue <MefFileModuleTypeLoader>();
            ModuleInfo info = this.CreateModuleInfo();

            // Flags
            bool progressChangedRaised = false;
            bool completedRaised       = false;

            // We subscribe to the events
            loader.ModuleDownloadProgressChanged += (o, e) => { progressChangedRaised = true; };
            loader.LoadModuleCompleted           += (o, e) => { completedRaised = true; };

            loader.LoadModuleType(info);

            Assert.IsTrue(progressChangedRaised);
            Assert.IsTrue(completedRaised);
        }
예제 #2
0
 public virtual void TestInitialise()
 {
     // Create MEF catalog.
     AggregateCatalog = CreateAggregateCatalog();
     ConfigureAggregateCatalog();
     AggregateCatalog = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(AggregateCatalog);
     ConfigureContainer();
     // Initialise modules to be tested.
     CompositionContainer.GetExportedValue <IModuleManager>().Run();
 }
 public void NullAggregateCatalogThrows()
 {
     try
     {
         DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(null);
         Assert.Fail("Expected exception not thrown");
     }
     catch (Exception)
     {
         // no op
     }
 }
        public void SingleContentControlRegionAdapterIsRegisteredWithContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            var newCatalog           = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(catalog);

            CompositionContainer container = new CompositionContainer(newCatalog);

            SetupServiceLocator(container);

            var exportedValue = container.GetExportedValue <ContentControlRegionAdapter>();

            Assert.IsNotNull(exportedValue);
        }
        public void SingleBindRegionContextToDependencyObjectBehaviorIsRegisteredWithContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            var newCatalog           = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(catalog);

            CompositionContainer container = new CompositionContainer(newCatalog);

            SetupServiceLocator(container);

            var exportedValue = container.GetExportedValue <BindRegionContextToDependencyObjectBehavior>();

            Assert.IsNotNull(exportedValue);
        }
        public void SingleMefFileModuleTypeLoaderIsRegisteredWithContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            var newCatalog           = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(catalog);

            CompositionContainer container = new CompositionContainer(newCatalog);

            container.ComposeExportedValue <AggregateCatalog>(catalog);
            SetupServiceLocator(container);

            var exportedValue = container.GetExportedValue <MefFileModuleTypeLoader>();

            Assert.IsNotNull(exportedValue);
        }
예제 #7
0
        /// <summary>
        /// Due to the usage of the service locator in Prism we need to resolve some types (ie Mef loading and Navigation)
        /// </summary>
        public ComposablePartCatalog GetPrismRequiredPartCatalog()
        {
            var prismAggregateCatalog = new AggregateCatalog();

            prismAggregateCatalog =
                DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(prismAggregateCatalog);

            var simpleCatalog =
                new SimpleCatalog(GetRequiredPrismPartsToRegister(
                                      prismAggregateCatalog));


            return(simpleCatalog);
        }
        public void SingleRegionLifetimeBehaviorIsRegisteredWithContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            var newCatalog           = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(catalog);

            CompositionContainer container = new CompositionContainer(newCatalog);

            foreach (var part in container.Catalog.Parts)
            {
                foreach (var export in part.ExportDefinitions)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Part contract name => '{0}'", export.ContractName));
                }
            }

            var exportedValue = container.GetExportedValue <RegionMemberLifetimeBehavior>();

            Assert.IsNotNull(exportedValue);
        }
        public void SingleIModuleManagerIsRegisteredWithContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            var newCatalog           = DefaultPrismServiceRegistrar.RegisterRequiredPrismServicesIfMissing(catalog);

            CompositionContainer container = new CompositionContainer(newCatalog);

            container.ComposeExportedValue <IModuleCatalog>(new ModuleCatalog());

            container.ComposeExportedValue <AggregateCatalog>(catalog);
            SetupLoggerForTest(container);
            SetupServiceLocator(container);

            DumpExportsFromCompositionContainer(container);

            var exportedValue = container.GetExportedValue <IModuleManager>();

            Assert.IsNotNull(exportedValue);
        }