public void edituser_get_should_return_view_and_viewmodel() { // Arrange User user = new User() { Id = Guid.NewGuid(), IsActivated = true }; _userService.Users.Add(user); // Act ViewResult result = _controller.EditUser(user.Id) as ViewResult; // Assert Assert.That(result, Is.Not.Null, "ViewResult"); UserViewModel model = result.ModelFromActionResult <UserViewModel>(); Assert.That(model, Is.Not.Null, "model"); Assert.That(model.Id, Is.EqualTo(user.Id), "model"); }
protected void btn_Click(object sender, EventArgs e) { if(null != hfID && hfID.Value.Length > 0) { managementController.EditUser(hfID.Value, txtUsername.Text, txtPassword.Text, txtFullname.Text, ddlTypeOfUser.SelectedValue); } else { managementController.AddUser(txtUsername.Text, txtPassword.Text, txtFullname.Text, ddlTypeOfUser.SelectedValue); } Response.Redirect("UserManagement.aspx"); }