public void SimpleExport_part_is_properly_exported()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExportedValue<SimpleExport>();
            Assert.That(simpleExport, Is.Not.Null);
        }
        public void SimpleExport_part_is_properly_exported()
        {
            var registry  = new ConfigurationPartRegistry("mef.configuration");
            var catalog   = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExportedValue <SimpleExport>();

            Assert.That(simpleExport, Is.Not.Null);
        }
        public void ExportWithPropertyImport_part_is_properly_exported_and_its_imports_are_satisfied()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var exportWithPropertyImport = container.GetExportedValue<ExportWithPropertyImport>();
            Assert.That(exportWithPropertyImport, Is.Not.Null);
            Assert.That(exportWithPropertyImport.SimpleImport, Is.Not.Null);
        }
        public void ExportWithPropertyImport_part_is_properly_exported_and_its_imports_are_satisfied()
        {
            var registry  = new ConfigurationPartRegistry("mef.configuration");
            var catalog   = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var exportWithPropertyImport = container.GetExportedValue <ExportWithPropertyImport>();

            Assert.That(exportWithPropertyImport, Is.Not.Null);
            Assert.That(exportWithPropertyImport.SimpleImport, Is.Not.Null);
        }
        public void SimpleExport_part_with_metadata_is_properly_exported()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExport<SimpleExportWithMetadata, ISimpleMetadata>("simple-export");
            Assert.That(simpleExport, Is.Not.Null);
            Assert.That(simpleExport.Metadata.IntValue, Is.EqualTo(1234));
            Assert.That(simpleExport.Metadata.StrValue, Is.EqualTo("some string"));
        }
        public void SimpleExport_part_with_metadata_is_properly_exported()
        {
            var registry  = new ConfigurationPartRegistry("mef.configuration");
            var catalog   = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExport <SimpleExportWithMetadata, ISimpleMetadata>("simple-export");

            Assert.That(simpleExport, Is.Not.Null);
            Assert.That(simpleExport.Metadata.IntValue, Is.EqualTo(1234));
            Assert.That(simpleExport.Metadata.StrValue, Is.EqualTo("some string"));
        }
        public void FakePart_is_exported_using_xml_configuration()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog = new ConventionCatalog(registry);

            var parts = new List<ComposablePartDefinition>(catalog.Parts);
            Assert.That(parts.Count, Is.Not.EqualTo(0));

            var exports = new List<ExportDefinition>(parts[0].ExportDefinitions);
            Assert.That(exports.Count, Is.EqualTo(1));

            var imports = new List<ImportDefinition>(parts[0].ImportDefinitions);
            Assert.That(imports.Count, Is.EqualTo(1));
            Assert.That(imports[0].ContractName, Is.EqualTo("somestring"));
            Assert.That(imports[0].IsRecomposable, Is.EqualTo(false));
            Assert.That(imports[0].IsPrerequisite, Is.EqualTo(false));
        }
        public void SimpleContract_part_with_metadata_is_properly_imported()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExport<SimpleContractImporter>();
            Assert.That(simpleExport, Is.Not.Null);
            Assert.That(simpleExport.Value.SimpleContracts, Is.Not.Null);
            Assert.That(simpleExport.Value.SimpleContracts.Length, Is.EqualTo(1));
            Assert.That(simpleExport.Value.SimpleContracts[0].Metadata.IntValue, Is.EqualTo(1234));
            Assert.That(simpleExport.Value.SimpleContracts[0].Metadata.StrValue, Is.EqualTo("some string"));

            Assert.That(simpleExport.Value.SimpleContractsNoMetadataInterface, Is.Not.Null);
            Assert.That(simpleExport.Value.SimpleContractsNoMetadataInterface.Length, Is.EqualTo(1));
            Assert.That(simpleExport.Value.SimpleContractsNoMetadataInterface[0].GetType(), Is.EqualTo(typeof(SimpleContract1)));
        }
        public void SimpleContract_part_with_metadata_is_properly_imported()
        {
            var registry  = new ConfigurationPartRegistry("mef.configuration");
            var catalog   = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExport <SimpleContractImporter>();

            Assert.That(simpleExport, Is.Not.Null);
            Assert.That(simpleExport.Value.SimpleContracts, Is.Not.Null);
            Assert.That(simpleExport.Value.SimpleContracts.Length, Is.EqualTo(1));
            Assert.That(simpleExport.Value.SimpleContracts[0].Metadata.IntValue, Is.EqualTo(1234));
            Assert.That(simpleExport.Value.SimpleContracts[0].Metadata.StrValue, Is.EqualTo("some string"));

            Assert.That(simpleExport.Value.SimpleContractsNoMetadataInterface, Is.Not.Null);
            Assert.That(simpleExport.Value.SimpleContractsNoMetadataInterface.Length, Is.EqualTo(1));
            Assert.That(simpleExport.Value.SimpleContractsNoMetadataInterface[0].GetType(), Is.EqualTo(typeof(SimpleContract1)));
        }
        public void FakePart_is_exported_using_xml_configuration()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog  = new ConventionCatalog(registry);

            var parts = new List <ComposablePartDefinition>(catalog.Parts);

            Assert.That(parts.Count, Is.Not.EqualTo(0));

            var exports = new List <ExportDefinition>(parts[0].ExportDefinitions);

            Assert.That(exports.Count, Is.EqualTo(1));

            var imports = new List <ImportDefinition>(parts[0].ImportDefinitions);

            Assert.That(imports.Count, Is.EqualTo(1));
            Assert.That(imports[0].ContractName, Is.EqualTo("somestring"));
            Assert.That(imports[0].IsRecomposable, Is.EqualTo(false));
            Assert.That(imports[0].IsPrerequisite, Is.EqualTo(false));
        }