diff options
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs index 29c4c2a9..ba82c0e8 100644 --- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs +++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs @@ -562,6 +562,20 @@ namespace Google.Protobuf.Collections Assert.IsFalse(values.Contains(null)); } + [Test] + public void ToString_StringToString() + { + var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } }; + Assert.AreEqual("{ \"foo\": \"bar\", \"x\": \"y\" }", map.ToString()); + } + + [Test] + public void ToString_UnsupportedKeyType() + { + var map = new MapField<byte, string> { { 10, "foo" } }; + Assert.Throws<ArgumentException>(() => map.ToString()); + } + private static KeyValuePair<TKey, TValue> NewKeyValuePair<TKey, TValue>(TKey key, TValue value) { return new KeyValuePair<TKey, TValue>(key, value); |