public void LoadWithCallback_TestMethod() { var mockCacheController = new Mock <CacheController> { CallBase = true }; var dataStore = new MemoryCacheDataStore { Storage = STORAGE }; mockCacheController.Object.SetupDataStore(dataStore); var callbackFired = false; mockCacheController.Object.LoadWithCallback(delegate { callbackFired = true; }); // TODO: Add a reset event here - Sara while (!callbackFired) { Thread.Sleep(500); } var data = mockCacheController.Object.Cache[0].Data as TestCacheData; Assert.IsNotNull(data, "ICacheData was not loaded properly from the xml"); Assert.IsTrue(data.Model == MODEL_STRING, "Model data was not loaded properly from the xml"); }
private static CacheController PrepareCache(out MemoryCacheDataStore dataStore, out CacheDataController data) { var cache = new CacheController(); dataStore = new MemoryCacheDataStore(); cache.SetupDataStore(dataStore); data = CacheFactory.CreateCacheData(cache, typeof(TestCacheData)); // The following line of code will force a reload var testData = data.Data as TestCacheData; Assert.IsNotNull(testData, "Test Data should not be null"); testData.Model = MODEL_DATA; // This will return us to an IsCached = false state - Sara cache.Invalidate(); return cache; }
private static void TestLoadWithDataInDataStore(ICacheController cache, MemoryCacheDataStore dataStore) { cache.Save(); var rawDataStore = dataStore.Storage; var dataStore2 = new MemoryCacheDataStore { Storage = rawDataStore }; var cache2 = new CacheController(); cache2.SetupDataStore(dataStore2); cache2.Load(); var data2 = cache2.Cache[0].Data as TestCacheData; Assert.IsNotNull(data2); Assert.IsTrue(data2.Model == MODEL_DATA, "Model text did not match"); }
public void Load_TestMethod() { var mockCacheController = new Mock <CacheController> { CallBase = true }; var dataStore = new MemoryCacheDataStore { Storage = STORAGE }; mockCacheController.Object.SetupDataStore(dataStore); mockCacheController.Object.Load(); var data = mockCacheController.Object.Cache[0].Data as TestCacheData; Assert.IsNotNull(data, "ICacheData was not loaded properly from the xml"); Assert.IsTrue(data.Model == MODEL_STRING, "Model data was not loaded properly from the xml"); }
public void Save_TestMethod() { var mockCacheController = new Mock <CacheController> { CallBase = true }; var mockCacheDataController = new Mock <CacheDataController> { CallBase = true }; var cacheData = new TestCacheData { Model = MODEL_STRING }; mockCacheDataController.Object.Initialize(cacheData); mockCacheController.Object.Add(mockCacheDataController.Object); var dataStore = new MemoryCacheDataStore(); mockCacheController.Object.SetupDataStore(dataStore); mockCacheController.Object.Save(); Assert.IsTrue(dataStore.Storage.Contains(MODEL_STRING)); }