public void Delete_WhenSuccessful_RedirectsToTasksIndex()
        {
            //ARRANGE
            var controller = new TaskController(_repository);

            //ACT
            var result = (RedirectToRouteResult)controller.Delete(1);

            //ASSERT
            Assert.IsNotNull(result);
            Assert.AreEqual("Task", result.RouteValues["Controller"]);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
        }
        public void Create_WhenAddingAValidTaskIsSuccessful_ReturnsToTaskIndex()
        {
            //ARRANGE: Create a mock that expectcs a call to Repository.Add
            var newTask = new Task { Id = 1, Description = "Task 1", IsCompleted = false };
            var mock = new Mock<IRepository<Task>>();
            mock.Setup(x => x.Add(newTask));
            var repository = mock.Object;

            var controller = new TaskController(repository);

            //ACT:
            RedirectToRouteResult result = (RedirectToRouteResult)controller.Create(newTask);

            //ASSERT:
            Assert.IsNotNull(result);
            Assert.AreEqual("Task", result.RouteValues["Controller"]);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
        }
 public void Setup()
 {
     var tasks = new List<Task> {
         new Task{ Id = 1, Description = "Task 1", IsCompleted = false },
         new Task{ Id = 2, Description = "Task 2", IsCompleted = false }
     };
     _fake = new Mock<IRepository<Task>>();
     _fake.Setup(x => x.GetAll()).Returns(tasks);
     _repository = _fake.Object;
     _controller = new TaskController(_repository);
 }