コード例 #1
0
        public void AddTypeNameAnnotationAsNeeded_DoesNotAddAnnotation()
        {
            // Arrange
            ODataEnumValue        enumValue = new ODataEnumValue("value");
            IEdmEnumTypeReference enumType  = new EdmEnumTypeReference(
                new EdmEnumType("TestModel", "EnumType"), isNullable: false);

            // Act
            ODataEnumSerializer.AddTypeNameAnnotationAsNeeded(enumValue, enumType, ODataMetadataLevel.MinimalMetadata);

            // Assert
            ODataTypeAnnotation annotation = enumValue.TypeAnnotation;

            Assert.Null(annotation);
        }
コード例 #2
0
        public void AddTypeNameAnnotationAsNeeded_DoesNotAddAnnotation(ODataMetadataLevel metadataLevel)
        {
            // Arrange
            ODataEnumValue        enumValue = new ODataEnumValue("value");
            IEdmEnumTypeReference enumType  = new EdmEnumTypeReference(
                new EdmEnumType("TestModel", "EnumType"), isNullable: false);

            // Act
            ODataEnumSerializer.AddTypeNameAnnotationAsNeeded(enumValue, enumType, metadataLevel);

            // Assert
            SerializationTypeNameAnnotation annotation = enumValue.GetAnnotation <SerializationTypeNameAnnotation>();

            Assert.Null(annotation);
        }
コード例 #3
0
        public void AddTypeNameAnnotationAsNeeded_AddAnnotation_InFullMetadataMode()
        {
            // Arrange
            ODataEnumValue        enumValue = new ODataEnumValue("value");
            IEdmEnumTypeReference enumType  = new EdmEnumTypeReference(
                new EdmEnumType("TestModel", "EnumType"), isNullable: false);

            // Act
            ODataEnumSerializer.AddTypeNameAnnotationAsNeeded(enumValue, enumType, ODataMetadataLevel.FullMetadata);

            // Assert
            SerializationTypeNameAnnotation annotation = enumValue.GetAnnotation <SerializationTypeNameAnnotation>();

            Assert.NotNull(annotation);
            Assert.Equal("TestModel.EnumType", annotation.TypeName);
        }