예제 #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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }