コード例 #1
0
        public void DeclaringTypeOFAnEntityNavigationCanBeAComplexType()
        {
            //Arrange
            Type        complexDeclaringType      = typeof(Address);
            Type        entityNavigationType      = typeof(City);
            EdmTypeKind expectedDeclaringTypeKind = EdmTypeKind.Complex;

            //Act
            ClientEdmModel        clientEdmModel = new ClientEdmModel(ODataProtocolVersion.V401);
            IEdmType              edmTypeOfComplexDeclaringType = clientEdmModel.GetOrCreateEdmType(complexDeclaringType);
            IEdmType              edmTypeOfEntityNavigationType = clientEdmModel.GetOrCreateEdmType(entityNavigationType);
            IEdmStructuredType    entiyNavigationType           = clientEdmModel.GetOrCreateEdmType(complexDeclaringType) as IEdmStructuredType;
            EdmNavigationProperty edmNavigationProperty         = EdmNavigationProperty.CreateNavigationPropertyWithPartner("City", ClientTypeUtil.ToEdmTypeReference(edmTypeOfEntityNavigationType, true), null, null, false, EdmOnDeleteAction.None, "Partner", ClientTypeUtil.ToEdmTypeReference(edmTypeOfComplexDeclaringType, true), null, null, false, EdmOnDeleteAction.None);
            EdmTypeKind           resultingDeclaringTypeKind    = edmNavigationProperty.DeclaringType.TypeKind;

            //Assert
            Assert.Equal(expectedDeclaringTypeKind, resultingDeclaringTypeKind);
        }