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