Пример #1
0
        [ActiveIssue(25498, TestPlatforms.AnyUnix)] // System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
        public void ImportCompletedGetExportedValueLazy()
        {
            var cat = CatalogFactory.CreateDefaultAttributed();
            CompositionContainer container = new CompositionContainer(cat);

            NotifyImportExportee.InstanceCount = 0;
            NotifyImportExportsLazy notifyee = container.GetExportedValue <NotifyImportExportsLazy>("NotifyImportExportsLazy");

            Assert.NotNull(notifyee);
            Assert.NotNull(notifyee.Imports);
            Assert.True(notifyee.NeedRefresh);
            Assert.Equal(3, notifyee.Imports.Count);
            Assert.Equal(0, NotifyImportExportee.InstanceCount);
            Assert.Equal(0, notifyee.realImports.Count);
            Assert.Equal(2, notifyee.RealImports.Count);
            Assert.Equal(1, notifyee.RealImports[0].Id);
            Assert.Equal(3, notifyee.RealImports[1].Id);
            Assert.Equal(2, NotifyImportExportee.InstanceCount);
        }
Пример #2
0
        public void ImportCompletedGetExportedValueLazy()
        {
            var cat = CatalogFactory.CreateDefaultAttributed();
            CompositionContainer container = new CompositionContainer(cat);

            NotifyImportExportee.InstanceCount = 0;
            NotifyImportExportsLazy notifyee = container.GetExportedValue <NotifyImportExportsLazy>("NotifyImportExportsLazy");

            Assert.IsNotNull(notifyee, "Expecting bound type");
            Assert.IsNotNull(notifyee.Imports, "Expecting Imports to be populated");
            Assert.IsTrue(notifyee.NeedRefresh, "Expecting import to put class in pending state");
            Assert.AreEqual(3, notifyee.Imports.Count, "Expecting 3 Exports before filtering");
            Assert.AreEqual(0, NotifyImportExportee.InstanceCount, "Not instance expected before pull");
            Assert.AreEqual(0, notifyee.realImports.Count, "Expecting collection to be empty before pull");
            Assert.AreEqual(2, notifyee.RealImports.Count, "Expecting 2 real values after pull");
            Assert.AreEqual(1, notifyee.RealImports[0].Id, "Expecting distinct activated instance");
            Assert.AreEqual(3, notifyee.RealImports[1].Id, "Expecting distinct  activated instance");
            Assert.AreEqual(2, NotifyImportExportee.InstanceCount, "2 instances expected after pull");
        }