public void SetupNotificationByKey_TestMethod() { ICacheController cacheController = new CacheController(); var mockCacheDataController = new Mock <CacheDataController> { CallBase = true }; var cacheData = new TestCacheData { Key = "SetupNotificationBykey" }; mockCacheDataController.Object.Initialize(cacheData); cacheController.Add(mockCacheDataController.Object); var loadStatusRaised = false; cacheController.SetupLoadNotification(typeof(TestCacheData), CacheNotificationAction.Add, delegate { loadStatusRaised = true; }); var invalidateRaised = false; cacheController.SetupInvalidateNotification(typeof(TestCacheData), CacheNotificationAction.Add, delegate { invalidateRaised = true; }); mockCacheDataController.Object.Load(); mockCacheDataController.Object.Invalidate(); Assert.IsTrue(loadStatusRaised, "LoadStatus event was not raised"); Assert.IsTrue(invalidateRaised, "Invalidate event was not raised"); }
public void Add_TestMethod() { ICacheController cacheController = new CacheController(); cacheController.Add(new CacheDataController()); Assert.IsTrue(cacheController.Cache.Count == 1); }
public void Remove_TestMethod() { ICacheController cacheController = new CacheController(); var cacheDataController = new CacheDataController(); cacheController.Add(cacheDataController); Assert.IsTrue(cacheController.Cache.Count == 1); cacheController.Remove(cacheDataController); Assert.IsTrue(cacheController.Cache.Count == 0); }
public void Clear_TestMethod() { ICacheController cacheController = new CacheController(); var mockCacheDataController = new Mock <CacheDataController> { CallBase = true }; mockCacheDataController.Object.Initialize(new Mock <ICacheData>().Object); cacheController.Add(mockCacheDataController.Object); cacheController.Clear(); mockCacheDataController.Verify(m => m.Clear(), Times.Once()); }
public void GetDataByType_TestMethod() { ICacheController cacheController = new CacheController(); var mockCacheDataController = new Mock <CacheDataController> { CallBase = true }; const string modelText = "GetDataByType"; var cacheData = new TestCacheData { Model = modelText }; mockCacheDataController.Object.Initialize(cacheData); cacheController.Add(mockCacheDataController.Object); var result = cacheController.GetData(typeof(TestCacheData)).First(); var model = result.Data as TestCacheData; Assert.IsNotNull(model, "Model should not be null"); Assert.IsTrue(model.Model.Contains(modelText)); }