Beispiel #1
0
        public void GetToDoByTask()
        {
            // Arrange
            var mockToDoRepository = new MockToDoRepository().MockGetToDoByTask();
            var homeController     = new HomeController(mockToDoRepository.Object);
            // Act
            var result = homeController.GetToDoByTask(taskName);

            //Assert
            Assert.IsAssignableFrom <JsonResult>(result);
        }
Beispiel #2
0
        public void ToDoList_DataPresent()
        {
            // Arrange
            var mockToDoRepository = new MockToDoRepository().MockToDoList();
            var homeController     = new HomeController(mockToDoRepository.Object);
            // Act
            var result = homeController.GetToDoList();

            // Assert
            Assert.IsAssignableFrom <ViewResult>(result);
        }
Beispiel #3
0
        public void Create_ModelStateInvalid()
        {
            // Arrange
            var mockToDoRepository = new MockToDoRepository().MockCreate();
            var homeController     = new HomeController(mockToDoRepository.Object);

            homeController.ModelState.AddModelError("Unit test", "Unit test error");
            // Act
            var result = homeController.Create(mockToDoList);

            // Assert
            Assert.IsAssignableFrom <ViewResult>(result);
        }
Beispiel #4
0
        public void Create_NoError()
        {
            // Arrange
            var mockToDoRepository = new MockToDoRepository().MockCreate();
            var homeController     = new HomeController(mockToDoRepository.Object);
            // Act
            var result = homeController.Create(mockToDoList);

            // Assert
            Assert.IsAssignableFrom <RedirectToActionResult>(result);
            var redirectToAction = (RedirectToActionResult)result;

            Assert.Equal("GetToDoList", redirectToAction.ActionName);
        }