public void Can_Edit_Admin_Profile() { // Arrange var mock = new Mock<IUsersRepository>(); mock.Setup(m => m.GetUser(It.IsAny<int>())).Returns( new Admins { UserID = 1, Login="******" } ); ProfileController target = new ProfileController(mock.Object); // Action Users result = (Users)target.Edit(2).Model; // Assert Assert.AreEqual("Skubi", result.Login); }
public void Can_Save_Valid_Changes() { // Arrange - create mock repository Mock<IUsersRepository> mock = new Mock<IUsersRepository>(); // Arrange - create the controller ProfileController target = new ProfileController(mock.Object); // Arrange - create a Admin Admins user = new Admins { Login = "******" }; // Act - try to save the product ActionResult result = target.Edit(user); // Assert - check that the repository was called mock.Verify(m => m.EditUser(user)); // Assert - check the method result type Assert.IsInstanceOfType(typeof(RedirectToRouteResult), result); }