public void ToArrayTest() { IWDT iwdt = new IWDT(); Assert.AreEqual(0, iwdt.ToArray().Length); iwdt.AddOrUpdate(HT(1, 1), Tuple.Create(2, 1), (k, v) => { throw new AssertFailedException(); return(default(Tuple <int, int>)); }); iwdt.AddOrUpdate(HT(2, 1), Tuple.Create(3, 1), (k, v) => { throw new AssertFailedException(); return(default(Tuple <int, int>)); }); iwdt.AddOrUpdate(HT(3, 1), Tuple.Create(4, 1), (k, v) => { throw new AssertFailedException(); return(default(Tuple <int, int>)); }); var array = iwdt.ToArray(); Assert.AreEqual(3, array.Length); var list = System.Linq.Enumerable.ToList(array); Assert.IsTrue(list.Contains(new KeyValuePair <Tuple <int, int>, Tuple <int, int> >(Tuple.Create(1, 1), Tuple.Create(2, 1)))); Assert.IsTrue(list.Contains(new KeyValuePair <Tuple <int, int>, Tuple <int, int> >(Tuple.Create(2, 1), Tuple.Create(3, 1)))); Assert.IsTrue(list.Contains(new KeyValuePair <Tuple <int, int>, Tuple <int, int> >(Tuple.Create(3, 1), Tuple.Create(4, 1)))); iwdt.Keys[Tuple.Create(1, 1)].IsGarbage = true; iwdt.Values[Tuple.Create(4, 1)].IsGarbage = true; array = iwdt.ToArray(); Assert.AreEqual(1, array.Length); Assert.AreEqual(new KeyValuePair <Tuple <int, int>, Tuple <int, int> >(Tuple.Create(2, 1), Tuple.Create(3, 1)), array[0]); }