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

            ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().BeNull();
        }
Esempio n. 2
0
        public void GetPropertyInitializationValueShouldReturnConstructorWithDataServiceCollectionConstructorParameters()
        {
            EdmEntityType               entityType              = new EdmEntityType("Namespace", "elementName");
            IEdmTypeReference           elementTypeReference    = new EdmTypeReferenceForTest(entityType, false);
            IEdmCollectionType          collectionType          = new EdmCollectionType(elementTypeReference);
            IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
            EdmPropertyForTest          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)");
        }
Esempio n. 3
0
        public void GetPropertyInitializationValueShouldReturnConstructorWithNoParametersForElementsInEntityTypeButNotUseDataServiceCollection()
        {
            EdmEntityType               entityType              = new EdmEntityType("Namespace", "elementName");
            IEdmTypeReference           elementTypeReference    = new EdmTypeReferenceForTest(entityType, false);
            IEdmCollectionType          collectionType          = new EdmCollectionType(elementTypeReference);
            IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
            EdmPropertyForTest          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>()");
        }
Esempio n. 4
0
        public void GetPropertyInitializationValueShouldReturnConstructorWithNoParametersForElementsInPrimitiveType()
        {
            EdmPrimitiveType            primitiveType           = new EdmPrimitiveType(EdmPrimitiveTypeKind.String);
            IEdmTypeReference           elementTypeReference    = new EdmTypeReferenceForTest(primitiveType, false);
            IEdmCollectionType          collectionType          = new EdmCollectionType(elementTypeReference);
            IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
            EdmPropertyForTest          property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", collectionTypeReference);

            ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().Be("new global::System.Collections.ObjectModel.Collection<string>()");
        }
Esempio n. 5
0
 public void GetPropertyInitializationValueShouldReturnConstructorWithDataServiceCollectionConstructorParameters()
 {
     EdmEntityType entityType = new EdmEntityType("Namespace", "elementName");
     IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(entityType, false);
     IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference);
     IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
     EdmPropertyForTest 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)");
 }
Esempio n. 6
0
 public void GetPropertyInitializationValueShouldReturnConstructorWithNoParametersForElementsInEntityTypeButNotUseDataServiceCollection()
 {
     EdmEntityType entityType = new EdmEntityType("Namespace", "elementName");
     IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(entityType, false);
     IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference);
     IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
     EdmPropertyForTest 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>()");
 }
Esempio n. 7
0
 public void GetPropertyInitializationValueShouldReturnConstructorWithNoParametersForElementsInPrimitiveType()
 {
     EdmPrimitiveType primitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String);
     IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(primitiveType, false);
     IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference);
     IEdmCollectionTypeReference collectionTypeReference = new EdmCollectionTypeReference(collectionType);
     EdmPropertyForTest property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", collectionTypeReference);
     ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().Be("new global::System.Collections.ObjectModel.Collection<string>()");
 }
Esempio n. 8
0
 public void GetPropertyInitializationValueShouldNotThrowOnPropertyNotInCollectionType()
 {
     EdmPrimitiveType primitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String);
     IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(primitiveType, false);
     EdmPropertyForTest property = new EdmPropertyForTest(new EdmStructruedTypeForTest(), "propertyName", edmTypeReference);
     ODataT4CodeGenerator.Utils.GetPropertyInitializationValue(property, false, template, context).Should().BeNull();
 }