Пример #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();
        }
Пример #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)");
        }
Пример #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>()");
        }
Пример #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>()");
        }
Пример #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)");
 }
Пример #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>()");
 }
Пример #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>()");
 }
Пример #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();
 }