public void GetUser_WithData_valid() { // Mock var user = new User() { Id = Guid.NewGuid(), UserName = "******", Email = "*****@*****.**", Roles = new List <Role> { new Role() { Id = Guid.NewGuid(), Name = "admin" } } }; _userRepository.GetUser(Arg.Any <Guid>()).Returns(user); // Execute var result = _sut.GetUser(Guid.NewGuid()); // Assert Assert.NotNull(result); Assert.NotNull(result.Roles); Assert.AreSame(user.Email, "*****@*****.**"); Assert.AreNotEqual(0, result.Roles.Count); Assert.AreSame("admin", result.Roles.First().Name); }
public async Task AddMember([FromRoute] string id, [FromRoute] string userId) { var user = _securityService.GetUser(userId); var role = _securityService.GetRole(id); if (user == null || role == null) { return; } await _securityService.AddUserToRole(user, role.Name); }
public ApplicationUser Get(string id) { var user = _securityService.GetUser(id, true); return(user); }