예제 #1
0
        public void RoundtripAlias()
        {
            var input = new ConventionTest {
                AliasTest = "Fourth"
            };
            var serializer = new Serializer();
            var writer     = new StringWriter();

            serializer.Serialize(writer, input, input.GetType());
            var serialized = writer.ToString();

            // Ensure serialisation is correct
            Assert.True(serialized.Contains("fourthTest: Fourth"));

            var output = serializer.Deserialize <ConventionTest>(serialized);

            // Ensure round-trip retains value
            Assert.AreEqual(input.AliasTest, output.AliasTest);
        }
예제 #2
0
        public void RoundtripAlias()
        {
            var input = new ConventionTest {
                AliasTest = "Fourth"
            };
            var serializer = new Serializer();
            var writer     = new StringWriter();

            serializer.Serialize(writer, input, input.GetType());
            var serialized = writer.ToString();

            // Ensure serialisation is correct
            Assert.Equal("fourthTest: Fourth", serialized.TrimEnd('\r', '\n'));

            var deserializer = new Deserializer();
            var output       = deserializer.Deserialize <ConventionTest>(new StringReader(serialized));

            // Ensure round-trip retains value
            Assert.Equal(input.AliasTest, output.AliasTest);
        }