public void UpdateProfilePostDataNoError() { _repository.Setup(x => x.UpdateProfile(It.IsAny <EditProfileViewModel>())); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.SeeProfile(new EditProfileViewModel()); Assert.IsNotNull(res); _repository.Verify(x => x.UpdateProfile(It.IsAny <EditProfileViewModel>()), Times.Exactly(1)); Assert.IsInstanceOfType(res, typeof(RedirectToActionResult)); }
public void UpdateProfilePostDataError() { _repository.Setup(x => x.UpdateProfile(It.IsAny <EditProfileViewModel>())).Throws(new Exception()); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.SeeProfile(new EditProfileViewModel()); Assert.IsNotNull(res); _repository.Verify(x => x.UpdateProfile(It.IsAny <EditProfileViewModel>()), Times.Exactly(1)); Assert.AreEqual(null, (res as ViewResult).ViewName); }
public void SeeProfileGetEditProfileModel() { _repository.Setup(x => x.GetEditProfileViewModel(It.IsAny <string>())).Returns(Task.FromResult(new EditProfileViewModel())); _controller = new FreelancerController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.SeeProfile() as ViewResult; Assert.IsNotNull(res); _repository.Verify(x => x.GetEditProfileViewModel(It.IsAny <string>()), Times.Exactly(1)); Assert.IsInstanceOfType(res.Model, typeof(EditProfileViewModel)); }