aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf.Test/Collections
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2015-08-10 08:47:07 +0100
committerGravatar Jon Skeet <jonskeet@google.com>2015-08-10 08:47:07 +0100
commit5be01ee65b987ef17e6418fbff5f161ed0f5cc87 (patch)
tree63f29c339c4752a7bcde80d3286e54c44c39a3e0 /csharp/src/Google.Protobuf.Test/Collections
parent3f45d7c11e200184cfc09fb92efe25a63df1eef1 (diff)
Implement ICollection.CopyTo (using Array) for MapField views.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/Collections')
-rw-r--r--csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs14
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 08f1a19c..29c4c2a9 100644
--- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
@@ -523,6 +523,20 @@ namespace Google.Protobuf.Collections
keys.CopyTo(array, 1);
CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
}
+
+ // Just test keys - we know the implementation is the same for values
+ [Test]
+ public void NonGenericViewCopyTo()
+ {
+ IDictionary map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ ICollection keys = map.Keys;
+ // Note the use of the Array type here rather than string[]
+ Array array = new string[4];
+ Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
+ Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
+ keys.CopyTo(array, 1);
+ CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
+ }
[Test]
public void KeysContains()