Exemplo n.º 1
0
        public void CreateParts_should_set_required_metadata_on_import_definition_to_required_metadata_on_import_convention()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var expectedRequiredMetadata =
                conventions.First().Imports.First().RequiredMetadata;

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.Cast <ContractBasedImportDefinition>().First();

            inspectedImportDefinition.RequiredMetadata.All(x =>
                                                           expectedRequiredMetadata.Contains(new RequiredMetadataItem(x.Key, x.Value)));
        }
Exemplo n.º 2
0
        public void CreateParts_should_set_metadata_on_export_definition_from_metadata_on_export_convention()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var expectedMetadata =
                conventions.First().Exports.First().Metadata;

            var inspectedExportDefinition =
                partDefinitions.First().ExportDefinitions.First();

            expectedMetadata.All(x =>
                                 inspectedExportDefinition.Metadata.Contains(
                                     new KeyValuePair <string, object>(x.Name, x.Value))).ShouldBeTrue();
        }
Exemplo n.º 3
0
        public void CreateParts_should_set_type_identity_on_import_deinfintion_to_contract_type_of_parameter_when_called_with_constructor()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                typeof(FakePart).GetConstructor(new Type[] { typeof(int), typeof(string[]) });

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.First();

            var expectedTypeIdentity =
                registry.ContractService.GetImportTypeIdentity(conventions.First().Imports.First(), member.GetParameters()[0].ParameterType);

            inspectedImportDefinition.ContractName.ShouldEqual(expectedTypeIdentity);
        }
Exemplo n.º 4
0
        public void CreateParts_should_set_type_identity_on_import_deinition_to_contract_type_from_import_convention()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                ReflectionServices.GetProperty <FakePart>(x => x.Delegate);

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.Cast <ContractBasedImportDefinition>().Skip(2).First();

            var expectedTypeIdentity =
                registry.ContractService.GetImportTypeIdentity(conventions.First().Imports.First(), member);

            inspectedImportDefinition.RequiredTypeIdentity.ShouldEqual(expectedTypeIdentity);
        }
Exemplo n.º 5
0
        public void CreateParts_should_set_contract_name_on_import_definition_to_contract_name_from_import_convention_using_contract_service_that_is_defined_on_registry()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                ReflectionServices.GetProperty <FakePart>(x => x.Delegate);

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.Skip(2).First();

            var expectedContractName =
                registry.ContractService.GetImportContractName(conventions.First().Imports.First(), member);

            inspectedImportDefinition.ContractName.ShouldEqual(expectedContractName);
        }
Exemplo n.º 6
0
        public void CreateParts_should_set_type_identity_metadata_on_export_definition_to_contract_type_from_export_convention_using_contract_service_that_is_defined_on_registry()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                ReflectionServices.GetProperty <FakePart>(x => x.Delegate);

            var inspectedExportDefinition =
                partDefinitions.First().ExportDefinitions.First();

            var expectedMetadata =
                new KeyValuePair <string, object>(CompositionConstants.ExportTypeIdentityMetadataName,
                                                  registry.ContractService.GetExportTypeIdentity(conventions.First().Exports.First(), member));

            inspectedExportDefinition.Metadata.Contains(expectedMetadata).ShouldBeTrue();
        }
        public void Parts_should_set_type_identity_on_import_deinfintion_to_contract_type_of_parameter_when_called_with_constructor()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                typeof(FakePart).GetConstructor(new Type[] { typeof(int), typeof(string[]) });

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.First();

            var expectedTypeIdentity =
                registry.ContractService.GetImportTypeIdentity(conventions.First().Imports.First(), member.GetParameters()[0].ParameterType);

            inspectedImportDefinition.ContractName.ShouldEqual(expectedTypeIdentity);
        }
        public void Parts_should_set_required_metadata_on_import_definition_to_required_metadata_on_import_convention()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var expectedRequiredMetadata =
                conventions.First().Imports.First().RequiredMetadata;

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.Cast<ContractBasedImportDefinition>().First();

            inspectedImportDefinition.RequiredMetadata.All(x =>
                expectedRequiredMetadata.Contains(new RequiredMetadataItem(x.Key, x.Value)));
        }
        public void Parts_should_set_type_identity_on_import_deinition_to_contract_type_from_import_convention()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                ReflectionServices.GetProperty<FakePart>(x => x.Delegate);

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.Cast<ContractBasedImportDefinition>().Skip(2).First();

            var expectedTypeIdentity =
                registry.ContractService.GetImportTypeIdentity(conventions.First().Imports.First(), member);

            inspectedImportDefinition.RequiredTypeIdentity.ShouldEqual(expectedTypeIdentity);
        }
        public void Parts_should_set_contract_name_on_import_definition_to_contract_name_from_import_convention_using_contract_service_that_is_defined_on_registry()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                ReflectionServices.GetProperty<FakePart>(x => x.Delegate);

            var inspectedImportDefinition =
                partDefinitions.First().ImportDefinitions.Skip(2).First();

            var expectedContractName =
                registry.ContractService.GetImportContractName(conventions.First().Imports.First(), member);

            inspectedImportDefinition.ContractName.ShouldEqual(expectedContractName);
        }
        public void Parts_should_set_type_identity_metadata_on_export_definition_to_contract_type_from_export_convention_using_contract_service_that_is_defined_on_registry()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var member =
                ReflectionServices.GetProperty<FakePart>(x => x.Delegate);

            var inspectedExportDefinition =
                partDefinitions.First().ExportDefinitions.First();

            var expectedMetadata =
                new KeyValuePair<string, object>(CompositionConstants.ExportTypeIdentityMetadataName,
                     registry.ContractService.GetExportTypeIdentity(conventions.First().Exports.First(), member));

            inspectedExportDefinition.Metadata.Contains(expectedMetadata).ShouldBeTrue();
        }
        public void Parts_should_set_metadata_on_export_definition_from_metadata_on_export_convention()
        {
            var registry =
                new NonEmptyRegistry();

            var conventions =
                registry.GetConventions();

            var partDefinitions =
                GetPartDefinitionsFromNonEmptyRegistry();

            var expectedMetadata =
                conventions.First().Exports.First().Metadata;

            var inspectedExportDefinition =
                partDefinitions.First().ExportDefinitions.First();

            expectedMetadata.All(x =>
                inspectedExportDefinition.Metadata.Contains(
                new KeyValuePair<string, object>(x.Name, x.Value))).ShouldBeTrue();
        }