public void ClaimTaskNoErrorRedirectToIndex() { _repository.Setup(x => x.SetDeveloperTask(It.IsAny <int>(), It.IsAny <string>())); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.ClaimTask(2); Assert.IsNotNull(res); _repository.Verify(x => x.SetDeveloperTask(It.IsAny <int>(), It.IsAny <string>()), Times.Exactly(1)); Assert.IsInstanceOfType(res, typeof(RedirectToActionResult)); }
public void ClaimTaskErrorRedirectToFindTask() { _repository.Setup(x => x.SetDeveloperTask(It.IsAny <int>(), It.IsAny <string>())).Throws(new Exception()); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.ClaimTask(2); Assert.IsNotNull(res); _repository.Verify(x => x.SetDeveloperTask(It.IsAny <int>(), It.IsAny <string>()), Times.Exactly(1)); Assert.AreEqual("FindTask", (res as ViewResult).ViewName); }