[ActiveIssue("https://github.com/dotnet/corefx/issues/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 BasicTestWithRequiredMetadata_WrongTypeConstraint() { var catalog = CatalogFactory.CreateDefaultAttributed(); var catalogExportProvider = new CatalogExportProvider(catalog); catalogExportProvider.SourceProvider = catalogExportProvider; Assert.Equal(0, catalogExportProvider.GetExports(ImportFromContractAndMetadata("MyExporterWithNoFoo", new string[] { "Foo" }, new Type[] { typeof(int) })).Count()); Assert.Equal(0, catalogExportProvider.GetExports(ImportFromContractAndMetadata("MyExporterWithFoo", new string[] { "Foo" }, new Type[] { typeof(int) })).Count()); Assert.Equal(0, catalogExportProvider.GetExports(ImportFromContractAndMetadata("MyExporterWithFoo", new string[] { "Foo", "Bar" }, new Type[] { typeof(int), typeof(int) })).Count()); Assert.Equal(0, catalogExportProvider.GetExports(ImportFromContractAndMetadata("MyExporterWithNoFoo", new string[] { "Foo" }, new Type[] { typeof(int) })).Count()); Assert.Equal(0, catalogExportProvider.GetExports(ImportFromContractAndMetadata("MyExporterWithFoo", new string[] { "Foo" }, new Type[] { typeof(int) })).Count()); }
protected override IEnumerable <Export> GetExportsCore( ImportDefinition definition, AtomicComposition atomicComposition) { IEnumerable <Export> exports = _exportProvider.GetExports(definition, atomicComposition); return(exports.Select(export => new Export(export.Definition, () => GetValue(export)))); }
public void Recomposition_PartDefWithNonRecomposableImportIsRemoved_ExportsMatchingImportChanged_ShouldNotBeRejected() { string dependencyContractName = "dependency"; var exportValue = new object(); var exporterPart = PartFactory.CreateExporter(dependencyContractName, exportValue); var importerPart = PartFactory.CreateImporter(dependencyContractName, false); var exporterCatalog = CatalogFactory.Create(exporterPart); var importerCatalog = CatalogFactory.Create(importerPart); var aggregateCatalog = CatalogFactory.CreateAggregateCatalog(importerCatalog, exporterCatalog); var provider = new CatalogExportProvider(aggregateCatalog); provider.SourceProvider = provider; var exports = provider.GetExports(importerPart.ImportDefinitions.Single()); Assert.AreEqual(exportValue, importerPart.Value, "Importer was not composed"); aggregateCatalog.Catalogs.Remove(importerCatalog); aggregateCatalog.Catalogs.Remove(exporterCatalog); Assert.AreEqual(exportValue, importerPart.Value, "Importer was unexpectedly recomposed"); }
public void GetExports_NoSourceProvider_ShouldThrowInvalidOperation() { var catalog = CatalogFactory.CreateAttributed(); var provider = new CatalogExportProvider(catalog); ExceptionAssert.Throws <InvalidOperationException>(() => provider.GetExports(ImportFromContract("Foo"))); }
[ActiveIssue("https://github.com/dotnet/corefx/issues/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 ComponentCatalogResolverGetStaticExport() { var catalog = CatalogFactory.CreateDefaultAttributed(); var catalogExportProvider = new CatalogExportProvider(catalog); catalogExportProvider.SourceProvider = catalogExportProvider; var exports = catalogExportProvider.GetExports(ImportFromContract("StaticString")); Assert.Equal(1, exports.Count()); Assert.Equal("StaticString", exports.First().Value); }
[ActiveIssue("https://github.com/dotnet/corefx/issues/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 BasicTest() { var catalog = CatalogFactory.CreateDefaultAttributed(); var catalogExportProvider = new CatalogExportProvider(catalog); catalogExportProvider.SourceProvider = catalogExportProvider; var testName = AttributedModelServices.GetContractName(typeof(CatalogComponentTest)); var testNameNonComponent = AttributedModelServices.GetContractName(typeof(CatalogComponentTestNonComponentPart)); var testInterfaceName = AttributedModelServices.GetContractName(typeof(ICatalogComponentTest)); Assert.Equal(1, catalogExportProvider.GetExports(ImportFromContract(testName)).Count()); Assert.Equal(0, catalogExportProvider.GetExports(ImportFromContract(testNameNonComponent)).Count()); var exports = catalogExportProvider.GetExports(ImportFromContract(testInterfaceName)); Assert.Equal(2, exports.Count()); foreach (var i in exports) { Assert.NotNull(i.Value); } }
[ActiveIssue("https://github.com/dotnet/corefx/issues/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 ComponentCatalogResolverComponentCatalogExportReference() { var catalog = CatalogFactory.CreateDefaultAttributed(); var catalogExportProvider = new CatalogExportProvider(catalog); catalogExportProvider.SourceProvider = catalogExportProvider; var exports = catalogExportProvider.GetExports(ImportFromContract(AttributedModelServices.GetContractName(typeof(MyExporterWithValidMetadata)))); Assert.Equal(1, exports.Count()); var export = exports.First(); Assert.Equal("world", export.Metadata["hello"]); Assert.IsType <MyExporterWithValidMetadata>(export.Value); }