aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2015-08-03 11:43:07 +0100
committerGravatar Jon Skeet <jonskeet@google.com>2015-08-03 14:03:11 +0100
commit0e30de3d6b99f79efc9ddafa9e60916a54524353 (patch)
tree5105ec1f557a67ff8fba348b11501b8c1f81c467 /csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
parentdb9f47a3ed78f55bb4eb8b8b8582a88eb64402d0 (diff)
JSON formatting for FieldMask
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs')
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
index f6e6488f..ecd7f46b 100644
--- a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
@@ -388,6 +388,24 @@ namespace Google.Protobuf
AssertJson("{ 'a': null, 'b': false, 'c': 10.5, 'd': 'text', 'e': [ 't1', 5 ], 'f': { 'nested': 'value' } }", message.ToString());
}
+ [Test]
+ public void FieldMaskStandalone()
+ {
+ var fieldMask = new FieldMask { Paths = { "", "single", "with_underscore", "nested.field.name", "nested..double_dot" } };
+ Assert.AreEqual(",single,withUnderscore,nested.field.name,nested..doubleDot", fieldMask.ToString());
+
+ // Invalid, but we shouldn't create broken JSON...
+ fieldMask = new FieldMask { Paths = { "x\\y" } };
+ Assert.AreEqual(@"x\\y", fieldMask.ToString());
+ }
+
+ [Test]
+ public void FieldMaskField()
+ {
+ var message = new TestWellKnownTypes { FieldMaskField = new FieldMask { Paths = { "user.display_name", "photo" } } };
+ AssertJson("{ 'fieldMaskField': 'user.displayName,photo' }", JsonFormatter.Default.Format(message));
+ }
+
/// <summary>
/// Checks that the actual JSON is the same as the expected JSON - but after replacing
/// all apostrophes in the expected JSON with double quotes. This basically makes the tests easier