public async Task Role_Updated_Distributed_Event_Test()
    {
        var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"));

        var permissionGrantsInRole = await PermissionGrantRepository.GetListAsync("R", role.Name);

        permissionGrantsInRole.ShouldNotBeNull();
        permissionGrantsInRole.Count.ShouldBeGreaterThan(0);
        var count = permissionGrantsInRole.Count;

        using (var uow = UowManager.Begin())
        {
            var identityResult = await RoleManager.SetRoleNameAsync(role, "TestModerator");

            identityResult.Succeeded.ShouldBeTrue();
            await RoleRepository.UpdateAsync(role);

            await uow.CompleteAsync();
        }

        role = await RoleRepository.GetAsync(role.Id);

        role.Name.ShouldBe("TestModerator");

        permissionGrantsInRole = await PermissionGrantRepository.GetListAsync("R", role.Name);

        permissionGrantsInRole.Count.ShouldBe(count);
    }
Example #2
0
    public async Task SetRoleNameAsync()
    {
        var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));

        role.ShouldNotBeNull();

        (await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue();

        role.Name.ShouldBe("teacher");
    }