public void WeakCacheCleanup() { // Create a weak cache. var newCache = new WeakCache <object, object>(EqualityComparer <object> .Default); const int opCount = 40000; // Insert new values and re-shuffle old values. Just check that the cache // cleanup code doesn't cause exceptions. for (int i = 0; i < opCount; i++) { newCache.Insert(i, GenerateInt32Object(rng)); object value; if (newCache.TryGet(GenerateInt32Object(rng), out value)) { newCache.Insert(GenerateInt32Object(rng), value); } } }