예제 #1
0
        public void SerializeTypePropertiesTest()
        {
            ITestType?type = new TestTypeTwo
            {
                TestPropertyOne = "B",
                TestPropertyTwo = 10
            };
            var mapping = new YamlMappingNode();
            var writer  = YamlObjectSerializer.NewWriter(mapping);

            writer.DataField(ref type, "test", null !);

            Assert.IsNotEmpty(mapping.Children);

            var testPropertyOne = (YamlScalarNode)mapping["test"]["testPropertyOne"];
            var testPropertyTwo = (YamlScalarNode)mapping["test"]["testPropertyTwo"];

            Assert.That(testPropertyOne.Value, Is.EqualTo("B"));
            Assert.That(testPropertyTwo.Value, Is.EqualTo("10"));
        }
예제 #2
0
        public void SerializeTypePropertiesTest()
        {
            ITestType?type = new TestTypeTwo
            {
                TestPropertyOne = "B",
                TestPropertyTwo = 10
            };
            var serMan  = IoCManager.Resolve <ISerializationManager>();
            var mapping = (MappingDataNode)serMan.WriteValue(type);

            Assert.IsNotEmpty(mapping.Children);

            var testPropertyOne = mapping.Get("testPropertyOne") as ValueDataNode;
            var testPropertyTwo = mapping.Get("testPropertyTwo") as ValueDataNode;

            Assert.NotNull(testPropertyOne);
            Assert.NotNull(testPropertyTwo);
            Assert.That(testPropertyOne !.Value, Is.EqualTo("B"));
            Assert.That(testPropertyTwo !.Value, Is.EqualTo("10"));
        }