public void EditRolesTest() { var role = new PersonRole() { Id = 1 }; var um = new FakeUserManager(); Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); uow.Setup(x => x.PersonRoleRepository.Update(role)); Mock <IHostingEnvironment> env = new Mock <IHostingEnvironment>(); PersonService ps = new PersonService(uow.Object); PersonController PC = new PersonController(uow.Object, env.Object, ps, um); var result = PC.EditRoles(new List <PersonRole>() { role }) as ViewResult; uow.Verify(x => x.Save()); }