public void DeserializeFiveFlagTest()
        {
            // Arrange
            var data       = 0;
            var rootNode   = YamlObjectSerializer_Test.YamlTextToNode(SerializedFiveFlag);
            var serializer = YamlObjectSerializer.NewReader(rootNode);

            // Act
            serializer.DataField(ref data, "generic_flags", 0, WithFormat.Flags <GenericFlagTag>());

            // Assert
            Assert.That(data, Is.EqualTo((int)GenericFlags.Five));
        }
        public void DeserializeZeroWithFlagTest()
        {
            // Arrange
            var data       = 0;
            var rootNode   = YamlObjectSerializer_Test.YamlTextToNode(SerializedZeroFlag);
            var serializer = YamlObjectSerializer.NewReader(rootNode);

            // Act
            serializer.DataField(ref data, "generic_flags_with_zero", 0, WithFormat.Flags <GenericFlagWithZeroTag>());

            // Assert
            Assert.That(data, Is.EqualTo(0));
        }
Пример #3
0
        public void DeserializeLegacyFormatTest()
        {
            // Arrange
            var data       = 0;
            var rootNode   = YamlObjectSerializer_Test.YamlTextToNode(SerializedThree);
            var serializer = YamlObjectSerializer.NewReader(rootNode);

            // Act
            serializer.DataField(ref data, "generic_constants", 0, WithFormat.Constants <GenericConstantTag>());

            // Assert
            Assert.That(data, Is.EqualTo((int)GenericConstants.Three));
        }
        public void SerializeZeroWithoutFlagTest()
        {
            // Arrange
            var data       = 0;
            var mapping    = new YamlMappingNode();
            var serializer = YamlObjectSerializer.NewWriter(mapping);

            // Act
            serializer.DataField(ref data, "generic_flags", 0, WithFormat.Flags <GenericFlagTag>(), alwaysWrite: true);

            // Assert
            var result = YamlObjectSerializer_Test.NodeToYamlText(mapping);

            Assert.That(result, Is.EqualTo(SerializedZeroNum));
        }
        public void SerializeFiveFlagTest()
        {
            // Arrange
            var data       = (int)GenericFlags.Five;
            var mapping    = new YamlMappingNode();
            var serializer = YamlObjectSerializer.NewWriter(mapping);

            // Act
            serializer.DataField(ref data, "generic_flags", 0, WithFormat.Flags <GenericFlagTag>());

            // Assert
            var result = YamlObjectSerializer_Test.NodeToYamlText(mapping);

            Assert.That(result, Is.EqualTo(SerializedOneFourFlag));
        }
        public void SerializeNonZeroWithZeroFlagDoesntShowZeroTest()
        {
            // Arrange
            var data       = (int)FlagsWithZero.Two;
            var mapping    = new YamlMappingNode();
            var serializer = YamlObjectSerializer.NewWriter(mapping);

            // Act
            serializer.DataField(ref data, "generic_flags_with_zero", 0, WithFormat.Flags <GenericFlagWithZeroTag>());

            // Assert
            var result = YamlObjectSerializer_Test.NodeToYamlText(mapping);

            Assert.That(result, Is.EqualTo(SerializedTwoWithZeroFlag));
        }
Пример #7
0
        public void SerializeOneConstantTest()
        {
            // Arrange
            var data       = (int)GenericConstants.One;
            var mapping    = new YamlMappingNode();
            var serializer = YamlObjectSerializer.NewWriter(mapping);

            // Act
            serializer.DataField(ref data, "generic_constants", 0, WithFormat.Constants <GenericConstantTag>());

            // Assert
            var result = YamlObjectSerializer_Test.NodeToYamlText(mapping);

            Assert.That(result, Is.EqualTo(SerializedOneConstant));
        }