aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers.Test/CompatTests/XmlCompatibilityTests.cs
blob: e204200d8e136c47a58a5dafade68755bd837d66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.IO;
using Google.ProtocolBuffers.Serialization;
using NUnit.Framework;

namespace Google.ProtocolBuffers.CompatTests
{
    [TestFixture]
    public class XmlCompatibilityTests : CompatibilityTests
    {
        protected override object SerializeMessage<TMessage, TBuilder>(TMessage message)
        {
            StringWriter text = new StringWriter();
            XmlFormatWriter writer = new XmlFormatWriter(text);
            writer.WriteMessage("root", message);
            return text.ToString();
        }

        protected override TBuilder DeerializeMessage<TMessage, TBuilder>(object message, TBuilder builder, ExtensionRegistry registry)
        {
            XmlFormatReader reader = new XmlFormatReader((string)message);
            return reader.Merge("root", builder, registry);
        }
    }
}