Exemple #1
0
            public void ShouldNotCacheWhenResultIsNull()
            {
                var key = "testNull";

                var result = _cache.AddOrGetExisting <TestData>(key, () => null);

                Assert.IsNull(result);

                result = _cache.AddOrGetExisting <TestData>(key, () => TestDataFactory.GetData());

                Assert.IsNotNull(result);
            }
Exemple #2
0
            public void ShouldAddCacheItemWhenPolicyNameIsSpecified()
            {
                var firstResult = _cache.AddOrGetExisting <TestData>("testData2", () => TestDataFactory.GetData(), "sixHours");

                // can we get the item back out?
                var secondResult = _cache.AddOrGetExisting <TestData>("testData2", () => { throw new Exception("I shouldn't have been called"); }, "sixHours");

                Assert.AreSame(firstResult, secondResult);
            }