Example #1
0
        public void TestCreateEntry_ReturnValue()
        {
            var cache = new InMemoryCache();

            cache.CreateEntry("key", new NewsArticle());
            Assert.IsTrue(cache.TryGetValue("key", out var value));
            Assert.NotNull(value);
        }
Example #2
0
        public void TestCreateEntry_DupKey_NoException_Override()
        {
            var cache = new InMemoryCache();

            cache.CreateEntry("key", new NewsArticle()
            {
                Id = 1
            });
            Assert.DoesNotThrow(() =>
            {
                cache.CreateEntry("key", new NewsArticle()
                {
                    Id = 2
                });
            });
            Assert.IsTrue(cache.TryGetValue("key", out var value));
            Assert.AreEqual(2, value.Id);
        }
Example #3
0
        public void TestCreateEntry_NoException()
        {
            var cache = new InMemoryCache();

            Assert.DoesNotThrow(() =>
            {
                cache.CreateEntry("key", new NewsArticle());
            });
        }
Example #4
0
        public void TestRemove_KeyExists_ShouldRemove()
        {
            var cache = new InMemoryCache();

            cache.CreateEntry("key", new NewsArticle());
            Assert.DoesNotThrow(() =>
            {
                cache.Remove("key");
            });

            Assert.IsFalse(cache.TryGetValue("key", out var value));
        }