Пример #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);
        }