aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers.Test/CompatTests/JsonCompatibilityTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ProtocolBuffers.Test/CompatTests/JsonCompatibilityTests.cs')
-rw-r--r--src/ProtocolBuffers.Test/CompatTests/JsonCompatibilityTests.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ProtocolBuffers.Test/CompatTests/JsonCompatibilityTests.cs b/src/ProtocolBuffers.Test/CompatTests/JsonCompatibilityTests.cs
new file mode 100644
index 00000000..30a08398
--- /dev/null
+++ b/src/ProtocolBuffers.Test/CompatTests/JsonCompatibilityTests.cs
@@ -0,0 +1,26 @@
+using System.IO;
+using System.Text;
+using Google.ProtocolBuffers.Serialization;
+using NUnit.Framework;
+
+namespace Google.ProtocolBuffers.CompatTests
+{
+ [TestFixture]
+ public class JsonCompatibilityTests : CompatibilityTests
+ {
+ protected override object SerializeMessage<TMessage, TBuilder>(TMessage message)
+ {
+ StringWriter sw = new StringWriter();
+ new JsonFormatWriter(sw)
+ .Formatted()
+ .WriteMessage(message);
+ return sw.ToString();
+ }
+
+ protected override TBuilder DeerializeMessage<TMessage, TBuilder>(object message, TBuilder builder, ExtensionRegistry registry)
+ {
+ new JsonFormatReader((string)message).Merge(builder);
+ return builder;
+ }
+ }
+} \ No newline at end of file