diff options
author | Jon Skeet <skeet@pobox.com> | 2015-10-07 17:08:25 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-10-07 17:08:25 +0100 |
commit | c34ed5c9bfd0577ccb00e259a8fc8f924a356819 (patch) | |
tree | 1e5b52e57900bbba566b31a58f7b0c1ecb1d9a54 /csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs | |
parent | 2842568f8d6759d34c0e48b428395851011597d2 (diff) | |
parent | 9ed6d4da3710daae65cdc60719ebff79a472b648 (diff) | |
download | protobuf-c34ed5c9bfd0577ccb00e259a8fc8f924a356819.tar.gz protobuf-c34ed5c9bfd0577ccb00e259a8fc8f924a356819.tar.bz2 protobuf-c34ed5c9bfd0577ccb00e259a8fc8f924a356819.zip |
Merge pull request #846 from jskeet/tostring
Support ToString in RepeatedField and MapField.
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); |