public async Task GetEditRoleViewModelTest() { string roleId = Guid.NewGuid().ToString("N"); var role = new IdentityRole { Id = roleId }; var user = new User(); user.Roles.Add(new IdentityUserRole { RoleId = roleId, Role = role, User = user }); user.Roles.Add(new IdentityUserRole { Role = new IdentityRole(), RoleId = "1234", User = user }); _userRepository.Setup(x => x.GetAsync("12")) .Returns(Task.FromResult(user)); _roleRepository.Setup(x => x.GetAll()) .Returns(Enumerable.Repeat(role, 5)); var result = await _userRolesMapper.GetEditRoleViewModel <IdentityRoleViewModel>("12"); Assert.That(result.Roles.Count(), Is.EqualTo(5)); Assert.That(((EditRoleViewModel)result).UserRoles.Count, Is.EqualTo(2)); }
public async Task <ActionResult> EditRole(string id = null, UsersMessageId?message = null) { ViewBag.StatusMessage = message == UsersMessageId.RoleAddedSuccess ? "Roles has been changed." : ""; var model = await _userRolesMapper.GetEditRoleViewModel(id); return(View(model)); }