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 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));
        }
        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));
        }