public void Edit_Get_ReturnsNotFound_WhenNonExistingHometaskId()
        {
            // Arrange
            int nonExistingHometaskId = 0;

            var hometaskServiceMock = Substitute.For <HometaskService>();

            hometaskServiceMock.GetHomeTask(nonExistingHometaskId).Returns(default(HomeTask));
            var controller = new HometaskController(hometaskServiceMock, null);

            // Act
            var result = controller.Edit(nonExistingHometaskId);

            // Assert
            var viewResult = Assert.IsType <NotFoundResult>(result);
        }
        public void Edit_Get_ReturnsViewResult_WithHometask()
        {
            // Arrange
            int existingHometaskId = 1;

            var hometaskServiceMock = Substitute.For <HometaskService>();

            hometaskServiceMock.GetHomeTask(existingHometaskId).Returns(new HomeTask());
            var controller = new HometaskController(hometaskServiceMock, null);

            // Act
            var result = controller.Edit(existingHometaskId);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <HomeTask>(viewResult.Model);
        }
        public void Edit_Post_RedirectToCourseHometasks()
        {
            // Arrange
            HomeTask homeTaskForEditing = new HomeTask();

            var homeTaskSericeMock = Substitute.For <HometaskService>();

            homeTaskSericeMock.UpdateHomeTask(homeTaskForEditing).Returns(true);
            var controller = new HometaskController(homeTaskSericeMock, null);

            // Act
            var result = controller.Edit(homeTaskForEditing);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Null(redirectToActionResult.ControllerName);
            Assert.Equal("CourseHometasks", redirectToActionResult.ActionName);
        }