diff options
author | alien <the-alien@live.ru> | 2016-03-17 15:19:04 +0300 |
---|---|---|
committer | alien <the-alien@live.ru> | 2016-03-18 22:59:50 +0300 |
commit | 0d32ab37fa94134427478d6776108e7cdb3e5e15 (patch) | |
tree | b0f5e3c9f9bf9097f739b98d0503d659abe974a9 /csharp/src/Google.Protobuf.Test/IssuesTest.cs | |
parent | 5e933847cc9e7826f1a9ee8b3dc1df4960b1ea5d (diff) | |
download | protobuf-0d32ab37fa94134427478d6776108e7cdb3e5e15.tar.gz protobuf-0d32ab37fa94134427478d6776108e7cdb3e5e15.tar.bz2 protobuf-0d32ab37fa94134427478d6776108e7cdb3e5e15.zip |
csharp: add support for the json_name option
Conflicts:
csharp/src/Google.Protobuf/JsonFormatter.cs
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/IssuesTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/IssuesTest.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/IssuesTest.cs b/csharp/src/Google.Protobuf.Test/IssuesTest.cs index a0350035..5b432edf 100644 --- a/csharp/src/Google.Protobuf.Test/IssuesTest.cs +++ b/csharp/src/Google.Protobuf.Test/IssuesTest.cs @@ -59,5 +59,23 @@ namespace Google.Protobuf // Underscores aren't reflected in the JSON.
Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString());
}
+
+ [Test]
+ public void JsonNameParseTest()
+ {
+ var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor));
+ var parser = new JsonParser(settings);
+
+ Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" },
+ parser.Parse<TestJsonName>("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }"));
+ }
+
+ [Test]
+ public void JsonNameFormatTest()
+ {
+ var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" };
+ Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }",
+ JsonFormatter.Default.Format(message));
+ }
}
}
|