public void Edit_Post_ShouldReturn_RedirectToAction() { // Arrange var postOperator = new PostOperatorViewModel { Id = 1 }; mockPostOperatorService.Setup(po => po.UpdatePostOperator(new PostOperatorDto())); mockPostOperatorService.Setup(po => po.GetById(postOperator.Id)).Returns(new PostOperatorDto()); PostOperatorController controller = new PostOperatorController(new DeliveryMessage(), mockPostOperatorService.Object); RedirectToRouteResult redirectResult = null; try { // Act redirectResult = controller.Edit(postOperator) as RedirectToRouteResult; } catch (Exception ex) { errorMessage = ex.Message + " | " + ex.StackTrace; } // Assert Assert.IsNotNull(redirectResult, errorMessage); }
public void Edit_Get_ShouldReturn_ViewAndListOfInvoices() { // Arrange var postOperatorDto = new PostOperatorDto { Id = 1, Name = "New Post", LinkToSearchPage = "link1", PathToLogoImage = "path1", IsActive = true, Notes = "notes 1" }; mockPostOperatorService.Setup(po => po.GetById(postOperatorDto.Id)).Returns(postOperatorDto); PostOperatorController controller = new PostOperatorController(new DeliveryMessage(), mockPostOperatorService.Object); PostOperatorViewModel postOperator = null; try { // Act result = controller.Edit(1) as ViewResult; postOperator = (PostOperatorViewModel)result.Model; } catch (Exception ex) { errorMessage = ex.Message + " | " + ex.StackTrace; } // Assert Assert.IsNotNull(result, errorMessage); Assert.IsNotNull(postOperator, errorMessage); }