Exemplo n.º 1
0
        public void GetPropertyInitializationValueShouldNotThrowOnPropertyNotInCollectionType()
        {
            var primitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String);
            IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(primitiveType, false);
            var property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", edmTypeReference);

            ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().BeNull();
        }
Exemplo n.º 2
0
        public void GetPropertyInitializationValueShouldReturnConstructorWithDataServiceCollectionConstructorParameters()
        {
            var entityType = new EdmEntityType("Namespace", "elementName");
            IEdmTypeReference           elementTypeReference    = new EdmTypeReferenceForTest(entityType, false);
            IEdmCollectionType          collectionType          = new EdmCollectionType(elementTypeReference);
            IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
            var property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", collectionTypeReference);

            ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, true, template, context).Should().Be("new global::Microsoft.OData.Client.DataServiceCollection<global::NamespacePrefix.elementName>(null, global::Microsoft.OData.Client.TrackingMode.None)");
        }
Exemplo n.º 3
0
        public void GetPropertyInitializationValueShouldReturnConstructorWithNoParametersForElementsInEntityTypeButNotUseDataServiceCollection()
        {
            var entityType = new EdmEntityType("Namespace", "elementName");
            IEdmTypeReference           elementTypeReference    = new EdmTypeReferenceForTest(entityType, false);
            IEdmCollectionType          collectionType          = new EdmCollectionType(elementTypeReference);
            IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
            var property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", collectionTypeReference);

            ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().Be("new global::System.Collections.ObjectModel.Collection<global::NamespacePrefix.elementName>()");
        }
Exemplo n.º 4
0
        public void GetPropertyInitializationValueShouldReturnConstructorWithNoParametersForElementsInPrimitiveType()
        {
            var primitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String);
            IEdmTypeReference           elementTypeReference    = new EdmTypeReferenceForTest(primitiveType, false);
            IEdmCollectionType          collectionType          = new EdmCollectionType(elementTypeReference);
            IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
            var property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", collectionTypeReference);

            ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().Be("new global::System.Collections.ObjectModel.Collection<string>()");
        }