public void EmptyCache() { // Arrange var timeSpan = TimeSpan.FromSeconds(int.Parse("20")); var className = "Project"; var methodName = "ToString()"; object obj = new object(); // Act var sut = new CachingService(timeSpan); sut.AddCacheValue(className, methodName, obj); sut.ResetCache(); // Assert Assert.ThrowsException <KeyNotFoundException>(() => sut.GetCacheValue(className, methodName)); }
public void AddValueToCache() { // Arrange var timeSpan = TimeSpan.FromSeconds(int.Parse("20")); var className = "Project"; var methodName = "ToString()"; object obj = new object(); // Act var sut = new CachingService(timeSpan); sut.AddCacheValue(className, methodName, obj); // Assert try { sut.GetCacheValue(className, methodName); } catch (Exception ex) { Assert.Fail("No exception is expected, but got: " + ex); } }