public void Add_AddMoreThanAvailable_Success() { var cache = new MemoryCache<int, string>(); for (int i = 0; i < DefaultMaxSize; ++i) { KeyValuePair<int, string>? removed; bool wasSaved = cache.Save(i, i.ToString(), out removed); Assert.IsTrue(wasSaved); Assert.IsNull(removed); } List<KeyValuePair<int, string>> values = cache.GetAll().ToList(); Assert.AreEqual(DefaultMaxSize, values.Count); for (int i = 0; i < DefaultMaxSize; ++i) { KeyValuePair<int, string>? removed; bool wasAdded = cache.Save(i, i.ToString(), out removed); Assert.IsTrue(wasAdded); Assert.IsNotNull(removed); Assert.AreEqual(i, removed.Value.Key); Assert.AreEqual(i.ToString(), removed.Value.Value); } values = cache.GetAll().ToList(); Assert.AreEqual(DefaultMaxSize, values.Count); }