public void BaseController_GetOrAddToCache_GetsValueFromCacheIfExists() { Mock <ICacheService> cacheServiceMock = new Mock <ICacheService>(MockBehavior.Strict); cacheServiceMock.Setup(x => x.GetCacheValue <Establishment>(It.IsAny <string>(), It.IsAny <string>())).Returns(GetEstablishment()); BaseControllerWrapper baseController = new BaseControllerWrapper(cacheServiceMock.Object, _configurationOptions); Establishment establishment = baseController.TestGetOrAddToCache("key", () => GetEstablishment(), "area"); Assert.NotNull(establishment); cacheServiceMock.Verify(x => x.GetCacheValue <Establishment>(It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public void BaseController_GetOrAddToCache_ThrowsArgumentException_Null_Key() { BaseControllerWrapper baseController = new BaseControllerWrapper(new LocalCacheService(), _configurationOptions); Assert.Throws <ArgumentNullException>(() => baseController.TestGetOrAddToCache(null, () => GetEstablishment(), "area")); }