public void UpdateTaskPostDataNoError() { _repository.Setup(x => x.UpdateTask(It.IsAny <EditTaskViewModel>())); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.UpdateTask(new EditTaskViewModel()); Assert.IsNotNull(res); _repository.Verify(x => x.UpdateTask(It.IsAny <EditTaskViewModel>()), Times.Exactly(1)); Assert.IsInstanceOfType(res, typeof(RedirectToActionResult)); }
public void UpdateTaskPostDataError() { _repository.Setup(x => x.UpdateTask(It.IsAny <EditTaskViewModel>())).Throws(new Exception()); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.UpdateTask(new EditTaskViewModel()); Assert.IsNotNull(res); _repository.Verify(x => x.UpdateTask(It.IsAny <EditTaskViewModel>()), Times.Exactly(1)); Assert.AreEqual(null, (res as ViewResult).ViewName); }
public void UpdateTaskEditViewModelCaller() { _repository.Setup(x => x.GetEditTaskViewModel(It.IsAny <int>())).Returns(new EditTaskViewModel()); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.UpdateTask(1) as ViewResult; Assert.IsNotNull(res); _repository.Verify(x => x.GetEditTaskViewModel(It.IsAny <int>()), Times.Exactly(1)); Assert.IsInstanceOfType(res.Model, typeof(EditTaskViewModel)); }