public void ManageUserControllerEditTest() { var userRepo = _IOC.GetService <IRepositoryBase <IdentityUser> >(); ManageUserController managerUser = new ManageUserController(userRepo); var httpContext = new DefaultHttpContext(); managerUser.TempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); ViewResult result = managerUser.Edit("1") as ViewResult; Assert.NotNull(result); Assert.IsType <ViewResult>(result); var model = result.Model as IdentityUser; Assert.Equal("Chris", model.UserName); }
public void ManageUserControllerUpdateUserTest() { var userRepo = _IOC.GetService <IRepositoryBase <IdentityUser> >(); ManageUserController managerUser = new ManageUserController(userRepo); var httpContext = new DefaultHttpContext(); managerUser.TempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); var currentUser = userRepo.FindAll().FirstOrDefault(); currentUser.UserName = "******"; ViewResult result = managerUser.Edit(currentUser) as ViewResult; var newUser = userRepo.FindAll().FirstOrDefault(); Assert.Equal("New Chris", newUser.UserName); }