コード例 #1
0
        public void GetExportContractName_should_return_convention_contract_name_when_not_null()
        {
            const string contract = "Contract";

            var convention =
                new ExportConvention
            {
                ContractName = x => contract,
                ContractType = x => typeof(string)
            };

            var results = this.Service.GetExportContractName(
                convention, ReflectionServices.GetField <FakePart>(x => x.Count));

            results.ShouldEqual(contract);
        }
コード例 #2
0
        public void GetExportContractName_should_return_convention_contract_type_when_not_null_and_contract_name_is_null()
        {
            var convention =
                new ExportConvention
            {
                ContractName = null,
                ContractType = x => typeof(string)
            };

            var results = this.Service.GetExportContractName(
                convention, ReflectionServices.GetField <FakePart>(x => x.Count));

            var expectedContractName =
                AttributedModelServices.GetContractName(convention.ContractType.Invoke(null));

            results.ShouldEqual(expectedContractName);
        }
コード例 #3
0
        public void GetImportContractName_should_return_contract_name_from_convention_when_not_null()
        {
            const string contract = "Contract";

            var convention =
                new ImportConvention
            {
                ContractName = x => contract
            };

            var service =
                GetServiceWithoutDefaultConventions();

            var result = service.GetImportContractName(
                convention, ReflectionServices.GetField <FakePart>(x => x.Count));

            result.ShouldEqual(contract);
        }
コード例 #4
0
        public void GetExportTypeIdentity_should_return_type_identity_from_convention_when_not_null()
        {
            var convention =
                new ExportConvention
            {
                ContractName = x => string.Empty,
                ContractType = x => typeof(string)
            };

            var service =
                GetServiceWithoutDefaultConventions();

            var result =
                service.GetExportTypeIdentity(convention, ReflectionServices.GetField <FakePart>(x => x.Count));

            var expectedTypeIdentity =
                AttributedModelServices.GetTypeIdentity(typeof(string));

            result.ShouldEqual(expectedTypeIdentity);
        }
コード例 #5
0
        public void GetExportContractName_should_return_contract_name_of_field_type_when_called_with_field_and_contract_name_and_type_are_null()
        {
            var member =
                ReflectionServices.GetField <FakePart>(x => x.Count);

            var convention =
                new ExportConvention
            {
                ContractName = null,
                ContractType = null,
                Members      = x => new[] { member }
            };

            var results =
                this.Service.GetExportContractName(convention, member);

            var expectedContractName =
                AttributedModelServices.GetContractName(member.FieldType);

            results.ShouldEqual(expectedContractName);
        }
コード例 #6
0
        public void GetImportContractName_should_return_type_identity_of_convention_contract_type_when_contract_type_is_null()
        {
            var contractType = typeof(string);

            var convention =
                new ImportConvention
            {
                ContractName = null,
                ContractType = x => contractType
            };

            var service =
                GetServiceWithoutDefaultConventions();

            var result = service.GetImportContractName(
                convention, ReflectionServices.GetField <FakePart>(x => x.Count));

            var expectedContractName =
                AttributedModelServices.GetTypeIdentity(contractType);

            result.ShouldEqual(expectedContractName);
        }
コード例 #7
0
        public void GetExportTypeIdentity_should_return_type_identify_of_field_type_when_called_with_field_member_and_convention_contract_type_is_null()
        {
            var convention =
                new ExportConvention
            {
                ContractName = null,
                ContractType = null
            };

            var member =
                ReflectionServices.GetField <FakePart>(x => x.Count);

            var service =
                GetServiceWithoutDefaultConventions();

            var result =
                service.GetExportTypeIdentity(convention, member);

            var expectedTypeIdentity =
                AttributedModelServices.GetTypeIdentity(member.FieldType);

            result.ShouldEqual(expectedTypeIdentity);
        }