public void TestItemCountNullCache()
        {
            mockCache.Expects.One.Method(_ => _.GetValue("Itemcount")).WithAnyArguments().WillReturn(null);
            var controller = new CacheController(new ToDoBL(mock.MockObject, mockCache.MockObject));
            var result     = controller.GetItemCount();

            // Assert
            Assert.IsTrue(Convert.ToString(result.Data) == "0", "Item Count");
        }
        public void TestItemCountExceptionCache()
        {
            mockCache.Expects.One.Method(_ => _.GetValue("Itemcount")).WithAnyArguments().Will(Throw.Exception(new Exception()));
            var controller = new CacheController(new ToDoBL(mock.MockObject, mockCache.MockObject));
            var result     = controller.GetItemCount();

            // Assert
            Assert.IsTrue(Convert.ToString(result.Data) == "error", "Item Count exception check");
        }
        public void TestGetItemCountException()
        {
            using (CacheController controller = Helpers.CreateCacheMockServiceObjectCache())
            {
                // Act
                var result = (JsonResult)controller.GetItemCount();

                //Assert
                Assert.True(result.Value.ToString() == "error", "Exception occur so error.");
            }
        }
        public void TestGetItemCountException()
        {
            // Arrange
            CacheController controller = new CacheController(new ToDoMockService());

            // Act

            var result = controller.GetItemCount();

            //Assert
            Assert.IsTrue(result.Data.ToString() == "error", "Exception occur so error.");
        }
        public void TestGetItemCount()
        {
            // Arrange
            CacheController controller = new CacheController(new ToDoBL(new ToDoRepository(), new DataCache()));

            // Act

            var resultUpdate = controller.GetItemCount();

            //Assert
            Assert.IsTrue(resultUpdate.Data.ToString() != "error", "Successfully get count");
        }
        public void TestGetItemCount()
        {
            // All contexts that share the same service provider will share the same InMemory database
            using (CacheController controller = Helpers.CreateCacheControllerObject())
            {
                // Act
                var resultUpdate = (JsonResult)controller.GetItemCount();

                //Assert
                Assert.True(resultUpdate.Value.ToString() != "error", "Successfully get count");
            }
        }
        public void CheckCacheCount()
        {
            int CacheCount = 0;

            #region GetcacheCount
            //Arrange
            // All contexts that share the same service provider will share the same InMemory database
            using (CacheController controller = Helpers.CreateCacheControllerObject())
            {
                //Actual
                var response = (JsonResult)controller.GetItemCount();
                int.TryParse(response.Value.ToString(), out CacheCount);
            }

            #endregion

            #region Add item
            //Arrange
            // All contexts that share the same service provider will share the same InMemory database
            using (ToDoController controllerAdd = Helpers.CreateToDoControllerObject())
            {
                string id = "100";
                Domain.Models.ToDoItem request = new Domain.Models.ToDoItem()
                {
                    Id = id, Name = "Test Data"
                };

                //Actual
                var responseAdd = controllerAdd.Create(request);
            }

            #endregion


            #region Validate Count
            //Arrange
            using (CacheController controllerValidate = Helpers.CreateCacheControllerObject())
            {
                //Actual
                var responseValidate      = (JsonResult)controllerValidate.GetItemCount();
                int CacheCountAfterInsert = 0;
                int.TryParse(responseValidate.Value.ToString(), out CacheCountAfterInsert);

                Assert.Equal((CacheCount + 1), CacheCountAfterInsert);
            }
            #endregion
        }
        public void CheckCacheCount()
        {
            int CacheCount = 0;

            #region GetcacheCount
            //Arrange
            var controller = new CacheController(new ToDoBL(new ToDoRepository(), new DataCache()));

            //Actual
            var response = controller.GetItemCount();
            int.TryParse(response.Data.ToString(), out CacheCount);
            #endregion


            #region Add item
            //Arrange
            var controllerAdd = new ToDoController(new ToDoBL(new ToDoRepository(), new DataCache()));

            int      id      = 100;
            ToDoItem request = new ToDoItem()
            {
                Id = id, Name = "Test Data"
            };

            //Actual
            var responseAdd = controllerAdd.Create(request);
            #endregion


            #region Validate Count
            //Arrange
            var controllerValidate = new CacheController(new ToDoBL(new ToDoRepository(), new DataCache()));

            //Actual
            var responseValidate      = controllerValidate.GetItemCount();
            int CacheCountAfterInsert = 0;
            int.TryParse(responseValidate.Data.ToString(), out CacheCountAfterInsert);

            Assert.AreEqual((CacheCount + 1), CacheCountAfterInsert);
            #endregion
        }