public void ICollectionCopyToThrowsArgumentIndexExceptionWithArrayIndexPastEnd() { var d = new HyperDictionary(); d.Add("foo", "bar"); d.Add("baz", "boo"); d.CopyTo(new KeyValuePair<string, object>[2], 1); }
public void Basics() { var d = new HyperDictionary <string, int>(3) { { 1, "Foo", "Blah", "Blubb" }, { 2, "Bar", "Blah", "Blubb" }, { 3, "Baz", "Blah", "Blubb" } }; Assert.AreEqual(1, d["Foo", "Blah", "Blubb"]); Assert.AreEqual(2, d["Bar", "Blah", "Blubb"]); Assert.AreEqual(3, d["Baz", "Blah", "Blubb"]); Assert.ThrowsException <ArgumentException>(() => d.Add(3, "Baz", "Blah", "Blubb")); d["Baz", "Blah", "Blubb"] = 4; Assert.AreEqual(4, d["Baz", "Blah", "Blubb"]); Assert.ThrowsException <KeyNotFoundException>(() => d["a", "b", "c"]); Assert.AreEqual(3, d.Count); d.Clear(); Assert.AreEqual(0, d.Count); }
public void ICollectionCopyToThrowsArgumentIndexExceptionWithTooSmallDestinationArray() { var d = new HyperDictionary(); d.Add("foo", "bar"); d.Add("baz", "boo"); d.CopyTo(new KeyValuePair<string, object>[1], 0); }
public void ICollectionCopyToWithZeroArrayIndexWorks() { var a = new KeyValuePair<string, object>[3]; a[0] = new KeyValuePair<string, object>("first", null); a[1] = new KeyValuePair<string, object>("second", "i'm second"); a[2] = new KeyValuePair<string, object>("third", "i'm third"); var d = new HyperDictionary(); d.Add("1st", "HyperDictionary first"); d.Add("2nd", "HyperDictionary second"); d.CopyTo(a, 0); Assert.AreEqual("1st", a[0].Key); Assert.AreEqual("HyperDictionary first", a[0].Value); Assert.AreEqual("2nd", a[1].Key); Assert.AreEqual("HyperDictionary second", a[1].Value); Assert.AreEqual("third", a[2].Key); Assert.AreEqual("i'm third", a[2].Value); }