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(); }
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)"); }
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>()"); }
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>()"); }