Esempio n. 1
0
        public void CacheStorage_Count()
        {
            var cacheStorage = new CacheStorage <string>();

            Assert.AreEqual(0, cacheStorage.Count);

            var e1 = cacheStorage.GetEntry("foo");
            var e2 = cacheStorage.GetEntry("bar");

            Assert.AreEqual(2, cacheStorage.Count);

            cacheStorage.ReleaseEntry(e1);
            cacheStorage.ReleaseEntry(e2);
            Assert.AreEqual(0, cacheStorage.Count);
        }
Esempio n. 2
0
        public void CacheStorage_ArgumentChecks()
        {
            var cacheStorage = new CacheStorage <string>();

            AssertEx.ThrowsException <ArgumentNullException>(() => new CacheStorage <string>(comparer: null), ex => Assert.AreEqual("comparer", ex.ParamName));
            AssertEx.ThrowsException <ArgumentNullException>(() => cacheStorage.GetEntry(value: null), ex => Assert.AreEqual("value", ex.ParamName));
            AssertEx.ThrowsException <ArgumentNullException>(() => cacheStorage.ReleaseEntry(entry: null), ex => Assert.AreEqual("entry", ex.ParamName));
            AssertEx.ThrowsException <ArgumentException>(() => cacheStorage.ReleaseEntry(new NullEntry()), ex => Assert.AreEqual("entry", ex.ParamName));
        }