public void GetClrTypeNameShouldReadEntitySingleTypeNameForEntityType() { var 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 GetClrTypeNameShouldReturnComplexTypeNameForComplexType() { var 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() { var 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 GetClrTypeNameShouldReturnPrimitiveTypeNameForNullableIEdmPrimitiveType() { var edmPrimitiveType = new EdmPrimitiveType(EdmPrimitiveTypeKind.String); IEdmTypeReference edmTypeReference = new EdmTypeReferenceForTest(edmPrimitiveType, true); ODataT4CodeGenerator.Utils.GetClrTypeName(edmTypeReference, false, template, context).Should().Be("string"); }
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 GetClrTypeNameShouldThrowOnNonIEdmSchemaElement() { var 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() { var 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() { var 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() { var 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 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>()"); }
public void GetClrTypeNameShouldReturnICollectionStructureTemplateForCollectionOfEntityType() { var 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 TestGetParametersString_WithSingleParameter() { var typeReference = new EdmTypeReferenceForTest(new EdmSchemaTypeForTest("Type1", "Test"), false); List <IEdmOperationParameter> parameters = new List <IEdmOperationParameter> { new EdmOperationParameter(new EdmAction("Test", "Action", typeReference, false, new EdmPropertyPathExpression("TestPath")), "par1", typeReference) }; string actualResult = EdmHelper.GetParametersString(parameters); string expectedResult = "(Test.Type1 par1)"; actualResult.ShouldBeEquivalentTo(expectedResult); }
public void GetClrTypeNameShouldReturnICollectionStructureTemplateForCollectionOfEnumType() { var 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>"); }