コード例 #1
0
        public async Task AddToRoleAsync()
        {
            using (var uow = _unitOfWorkManager.Begin())
            {
                var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.Normalize("david"));

                user.ShouldNotBeNull();
                user.Roles.ShouldBeEmpty();

                await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.Normalize("moderator"));

                user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId);

                await uow.CompleteAsync();
            }
        }