public void TestDeleteExceptionCache() { mockCache.Expects.One.Method(_ => _.Remove("Itemcount")).WithAnyArguments().Will(Throw.Exception(new Exception())); var controller = new CacheController(new ToDoBL(mock.MockObject, mockCache.MockObject)); var result = controller.DeleteCache(); // Assert Assert.IsTrue(Convert.ToString(result.Data) == "error", "remove exception check"); }
public void TestDeleteCache() { mockCache.Expects.One.Method(_ => _.Remove("Itemcount")).WithAnyArguments().WillReturn(true); var controller = new CacheController(new ToDoBL(mock.MockObject, mockCache.MockObject)); var result = controller.DeleteCache(); // Assert Assert.IsTrue(Convert.ToString(result.Data) == "", "Item Count deleted successfully"); }
public void TestToDoDeleteCacheException() { // Arrange CacheController controller = new CacheController(new ToDoMockService()); //Act var result = controller.DeleteCache(); //Assert Assert.IsTrue(result.Data.ToString() == "error", "Exception occur so error."); }
public void TestDeleteCache() { // Arrange CacheController controller = new CacheController(new ToDoBL(new ToDoRepository(), new DataCache())); // Act var resultDelete = controller.DeleteCache(); //Assert Assert.IsTrue(string.IsNullOrEmpty(resultDelete.Data.ToString()), "Deleted successfully"); }
public void TestToDoDeleteCacheException() { using (CacheController controller = Helpers.CreateCacheMockServiceObjectCache()) { //Act var result = (JsonResult)controller.DeleteCache(); //Assert Assert.True(result.Value.ToString() == "error", "Exception occur so error."); } }
public void TestDeleteCache() { // All contexts that share the same service provider will share the same InMemory database using (CacheController controller = Helpers.CreateCacheControllerObject()) { // Act var resultDelete = (JsonResult)controller.DeleteCache(); //Assert Assert.True(string.IsNullOrEmpty(resultDelete.Value.ToString()), "Deleted successfully"); } }
protected T GetCache <T>(string key, string urlJson, int time) where T : new() { if (ConfigCache.EnableCache != 1) { return(GetObjJson <T>(urlJson)); } if (Cache.KeyExistsCache(key)) { var data = (T)Cache.GetCache(key); if (data == null) { Cache.DeleteCache(key); data = GetObjJson <T>(urlJson); Cache.Set(key, data, time); } return(data); } var datas = GetObjJson <T>(urlJson); Cache.Set(key, datas, time); return(datas); }