Пример #1
0
        public void UpdateUser_EveryTime_valid()
        {
            // Mock

            var userModel = new User()
            {
                Id       = Guid.NewGuid(),
                UserName = "******",
                Email    = "*****@*****.**",
                Roles    = new List <Role> {
                    new Role()
                    {
                        Id   = Guid.NewGuid(),
                        Name = "manager"
                    }
                }
            };

            _userRepository.Update(Arg.Any <User>());

            // Execute
            _sut.UpdateUser(userModel);

            // Assert
            _userRepository.Received(1).Update(Arg.Any <User>());
        }
Пример #2
0
        public async Task <ApplicationUser> Put(string id, [FromBody] ApplicationUser user)
        {
            user.Id = id;
            foreach (var role in user.UserRoles)
            {
                role.UserId = user.Id;
            }
            foreach (var claim in user.UserClaims)
            {
                claim.UserId = user.Id;
            }
            user = await _securityService.UpdateUser(user);

            return(user);
        }