public void TestEnumerators() { TimeSpan cacheLifeTime = TimeSpan.FromMinutes(5); MemoryCachingService service = new MemoryCachingService(cacheLifeTime); Foobar cachable = GetCachableObject(); string cachableKey = this.cachableKey; service.Cache(cachableKey, cachable); IEnumerator <KeyValuePair <string, ICachedObjectBasic> > typedEnumerator = service.GetEnumerator(); IEnumerator enumerator = ((IEnumerable)service).GetEnumerator(); typedEnumerator.MoveNext(); enumerator.MoveNext(); Assert.Equal(cachable, (Foobar)((ICachedObjectBasic)(typedEnumerator.Current).Value).UntypedValue); Assert.Equal(cachable, (Foobar)((ICachedObjectBasic)((KeyValuePair <string, ICachedObjectBasic>) (enumerator.Current)).Value).UntypedValue); }