예제 #1
0
        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");
        }
예제 #2
0
        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");
        }
예제 #3
0
        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");
        }
예제 #4
0
        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>");
        }
예제 #5
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();
        }
예제 #6
0
        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>();
        }
예제 #7
0
        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>");
        }
예제 #8
0
        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>");
        }
예제 #9
0
        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>");
        }
예제 #10
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>()");
        }
예제 #11
0
        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>");
        }
예제 #12
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>()");
        }
예제 #13
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)");
        }
예제 #14
0
        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>");
        }
예제 #15
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>()");
 }
예제 #16
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();
 }
예제 #17
0
 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>");
 }
예제 #18
0
        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>");
        }
예제 #19
0
 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>");
 }
예제 #20
0
 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>");
 }
예제 #21
0
 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>");
 }
예제 #22
0
 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");
 }
예제 #23
0
 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");
 }
예제 #24
0
 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>");
 }
예제 #25
0
 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");
 }
예제 #26
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>()");
 }
예제 #27
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)");
 }
예제 #28
0
 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>();
 }