public void CacheDictionary_Enumerate() { var cd = new CacheDictionary<string, int>(EqualityComparer<string>.Default); cd.GetOrAdd("foo", s => s == null ? 0 : s.Length); cd.GetOrAdd(key: null, s => s == null ? 0 : s.Length); var res = cd.ToArray(); Assert.AreEqual(2, res.Length); Assert.IsTrue(res.Any(x => x.Key == null && x.Value == 0)); Assert.IsTrue(res.Any(x => x.Key == "foo" && x.Value == 3)); Assert.IsNotNull(((IEnumerable)cd).GetEnumerator()); }