public void TryGetValue_ReturnsDefaultIfNotExists() { var cache = new NanoCache <string, int>(); cache.TryGetValue("item", out var value); Assert.AreEqual(0, value); }
public void TryGetValue_ReturnsTrueIfItemDoesExist() { var cache = new NanoCache <string, int> { ["item"] = 1234 }; Assert.IsTrue(cache.TryGetValue("item", out _)); }
public void TryGetValue_ReturnsItemIfExists() { var cache = new NanoCache <string, int> { ["item"] = 1234 }; cache.TryGetValue("item", out var value); Assert.AreEqual(1234, value); }
public void TryGetValue_ReturnsFalseIfItemExpired() { var cache = new NanoCache <string, int>(); cache.Set("item", 1234, 10); Thread.Sleep(100); Assert.IsFalse(cache.TryGetValue("item", out _)); }
public void Count_IsUpdatedWhenExpiredItemIsFlushed1() { var cache = new NanoCache <string, int>(); cache.Set("1", 1, 10); Thread.Sleep(100); cache.TryGetValue("1", out _); Assert.AreEqual(0, cache.Count); }
public void TryGetValue_ThrowsException_IfKeyIsNull() { var cache = new NanoCache <string, int>(); Assert.Throws <ArgumentNullException>(() => cache.TryGetValue(null, out _)); }
public void TryGetValue_ReturnsFalseIfItemDoesNotExist() { var cache = new NanoCache <string, int>(); Assert.IsFalse(cache.TryGetValue("item", out _)); }