public void GetClrTypeNameShouldReadEntitySingleTypeNameForEntityType() { EdmEntityType entityType = new EdmEntityType("Namespace", "name"); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(entityType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context, isEntitySingleType: true).Should().Be("global::NamespacePrefix.nameSingle"); }
public void GetClrTypeNameShouldReturnPrimitiveTypeNameForNullableIEdmPrimitiveType() { EdmPrimitiveType edmPrimitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(edmPrimitiveType, true); ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context).Should().Be("string"); }
public void GetClrTypeNameShouldReturnComplexTypeNameForComplexType() { EdmComplexType complexType = new EdmComplexType("Namespace", "name"); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(complexType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context).Should().Be("global::NamespacePrefix.name"); }
public void GetClrTypeNameShouldReturnSystemNullableStructureTemplate() { EdmPrimitiveType edmPrimitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.DateTimeOffset); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(edmPrimitiveType, true); ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context).Should().Be("global::System.Nullable<global::System.DateTimeOffset>"); }
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 GetClrTypeNameShouldThrowOnNonIEdmSchemaElement() { EdmTypeForTest edmType = new EdmTypeForTest("name"); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(edmType, false); Action getName = () => ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context); getName.ShouldThrow <Exception>(); }
public void GetClrTypeNameShouldReturnDataServiceCollectionStructureTemplate() { EdmEntityType entityType = new EdmEntityType("Namespace", "elementName"); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(entityType, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, true, template, context).Should().Be("global::Microsoft.OData.Client.DataServiceCollection<global::NamespacePrefix.elementName>"); }
public void GetClrTypeNameShouldReturnObservableCollectionStructureTemplate() { EdmComplexType complexType = new EdmComplexType("Namespace", "elementName"); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(complexType, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, true, template, context).Should().Be("global::System.Collections.ObjectModel.ObservableCollection<global::NamespacePrefix.elementName>"); }
public void GetClrTypeNameShouldReturnObjectModelCollectionStructureTemplate() { EdmPrimitiveType primitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(primitiveType, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, false, template, context).Should().Be("global::System.Collections.ObjectModel.Collection<string>"); }
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>()"); }
public void GetClrTypeNameShouldReturnICollectionStructureTemplateForCollectionOfEntityType() { EdmEntityType entityType = new EdmEntityType("Namespace", "elementName"); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(entityType, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, false, template, context, true, true, true) .Should().Be("global::System.Collections.Generic.ICollection<global::NamespacePrefix.elementName>"); }
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 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 GetClrTypeNameShouldReturnICollectionStructureTemplateForCollectionOfEnumType() { EdmEnumType gender = new EdmEnumType("Namespace", "Gender", EdmPrimitiveTypeKind.Byte, true); gender.AddMember("Male", new EdmEnumMemberValue(1)); gender.AddMember("Female", new EdmEnumMemberValue(2)); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(gender, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, false, template, context, true, true, true) .Should().Be("global::System.Collections.Generic.ICollection<global::NamespacePrefix.Gender>"); }
public void GetClrTypeNameShouldReturnICollectionStructureTemplateForCollectionOfEnumType() { EdmEnumType gender = new EdmEnumType("Namespace", "Gender", EdmPrimitiveTypeKind.Byte, true); gender.AddMember("Male", new EdmIntegerConstant(1)); gender.AddMember("Female", new EdmIntegerConstant(2)); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(gender, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, false, template, context, true, true, true) .Should().Be("global::System.Collections.Generic.ICollection<global::NamespacePrefix.Gender>"); }
public void GetClrTypeNameShouldReturnICollectionStructureTemplateForCollectionOfPrimitiveType() { EdmPrimitiveType primitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String); IEdmTypeReference elementTypeReference = new EdmTypeReferenceForTest(primitiveType, false); IEdmCollectionType collectionType = new EdmCollectionType(elementTypeReference); IEdmTypeReference collectionTypeReference = new EdmTypeReferenceForTest(collectionType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(collectionTypeReference, false, template, context, true, true, true) .Should().Be("global::System.Collections.Generic.ICollection<string>"); }
public void GetClrTypeNameShouldReadEntitySingleTypeNameForEntityType() { EdmEntityType entityType = new EdmEntityType("Namespace", "name"); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(entityType, false); ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context, isEntitySingleType:true).Should().Be("global::NamespacePrefix.nameSingle"); }
public void GetClrTypeNameShouldThrowOnNonIEdmSchemaElement() { EdmTypeForTest edmType = new EdmTypeForTest("name"); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(edmType, false); Action getName = () => ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context); getName.ShouldThrow<Exception>(); }