Ejemplo n.º 1
0
        public void CreateParts_should_properly_extract_closed_generic_constructor_argument_when_importing_collection_and_when_contract_type_is_not_specified()
        {
            var exportConvention =
                new ExportConvention
            {
                Members      = t => new[] { t },
                ContractType = x => typeof(ConventionPart4),
            };

            var importConvention =
                new ImportConvention
            {
                Members = t => new[] { typeof(ConventionPart4).GetConstructors().Single() }
            };

            var convention =
                new PartConvention();

            convention.Imports.Add(importConvention);
            convention.Exports.Add(exportConvention);
            convention.Condition = t => t == typeof(ConventionPart4);

            var registry =
                new FakePartRegistry2(convention);
            ConventionPartCreator creator = new ConventionPartCreator(registry);
            var partDefinition            = creator.CreateParts().First();
            var importDefinitin           = partDefinition.ImportDefinitions.Single();

            importDefinitin.ContractName.ShouldEqual("MefContrib.Hosting.Conventions.Tests.IRepository(System.String)");
        }
Ejemplo n.º 2
0
        public void CreateParts_should_properly_extract_closed_generic_type_parameter()
        {
            var exportConvention =
                new ExportConvention
            {
                Members      = t => new[] { t },
                ContractType = x => typeof(ConventionPart2),
            };

            var importConvention =
                new ImportConvention
            {
                Members      = t => new[] { ReflectionServices.GetProperty <ConventionPart2>(p => p.Repository) },
                ContractType = x => typeof(IRepository <string>)
            };

            var convention =
                new PartConvention();

            convention.Imports.Add(importConvention);
            convention.Exports.Add(exportConvention);
            convention.Condition = t => t == typeof(ConventionPart2);

            var registry =
                new FakePartRegistry2(convention);
            ConventionPartCreator creator = new ConventionPartCreator(registry);
            var partDefinition            = creator.CreateParts().First();

            partDefinition.ImportDefinitions.Single().ContractName.ShouldEqual("MefContrib.Hosting.Conventions.Tests.IRepository(System.String)");
        }
Ejemplo n.º 3
0
        private static IEnumerable <ComposablePartDefinition> GetPartDefinitionsFromNonEmptyRegistry()
        {
            var registry =
                new NonEmptyRegistry();

            var creator =
                new ConventionPartCreator(registry);

            return(creator.CreateParts());
        }
        private static IEnumerable<ComposablePartDefinition> GetPartDefinitionsFromNonEmptyRegistry()
        {
            var registry =
                new NonEmptyRegistry();

            var creator =
                new ConventionPartCreator(registry);

            return creator.CreateParts();
        }
        public void CreateParts_should_properly_extract_closed_generic_constructor_argument_when_importing_collection_and_when_contract_type_is_not_specified()
        {
            var exportConvention =
                new ExportConvention
                {
                    Members = t => new[] { t },
                    ContractType = x => typeof(ConventionPart4),
                };

            var importConvention =
                new ImportConvention
                {
                    Members = t => new[] { typeof(ConventionPart4).GetConstructors().Single() }
                };

            var convention =
                new PartConvention();

            convention.Imports.Add(importConvention);
            convention.Exports.Add(exportConvention);
            convention.Condition = t => t == typeof(ConventionPart4);

            var registry =
                new FakePartRegistry2(convention);
            ConventionPartCreator creator = new ConventionPartCreator(registry);
            var partDefinition = creator.CreateParts().First();
            var importDefinitin = partDefinition.ImportDefinitions.Single();
            importDefinitin.ContractName.ShouldEqual("MefContrib.Hosting.Conventions.Tests.IRepository(System.String)");
        }
        public void CreateParts_should_properly_extract_closed_generic_type_parameter()
        {
            var exportConvention =
                new ExportConvention
                {
                    Members = t => new[] { t },
                    ContractType = x => typeof(ConventionPart2),
                };

            var importConvention =
                new ImportConvention
                {
                    Members = t => new[] { ReflectionServices.GetProperty<ConventionPart2>(p => p.Repository) },
                    ContractType = x => typeof(IRepository<string>)
                };

            var convention =
                new PartConvention();

            convention.Imports.Add(importConvention);
            convention.Exports.Add(exportConvention);
            convention.Condition = t => t == typeof(ConventionPart2);

            var registry =
                new FakePartRegistry2(convention);
            ConventionPartCreator creator = new ConventionPartCreator(registry);
            var partDefinition = creator.CreateParts().First();
            partDefinition.ImportDefinitions.Single().ContractName.ShouldEqual("MefContrib.Hosting.Conventions.Tests.IRepository(System.String)");
        }