public void CreateRole()
        {
            using (RoleStore <IdentityRole> store = roleFixture.CreateRoleStore())
            {
                using (RoleManager <IdentityRole> manager = roleFixture.CreateRoleManager(store))
                {
                    string roleNew    = string.Format("TestRole_{0}", Guid.NewGuid());
                    var    role       = new IdentityRole(roleNew);
                    var    start      = DateTime.UtcNow;
                    var    createTask = manager.CreateAsync(role);
                    createTask.Wait();

                    output.WriteLine("CreateRoleAsync: {0} seconds", (DateTime.UtcNow - start).TotalSeconds);

                    CurrentRole = role;
                    WriteLineObject <IdentityRole>(CurrentRole);

                    try
                    {
                        var task = store.CreateAsync(null);
                        task.Wait();
                    }
                    catch (Exception ex)
                    {
                        Xunit.Assert.NotNull(ex);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public async Task AddRemoveRoleClaim()
        {
            using (RoleStore <IdentityRole> store = roleFixture.CreateRoleStore())
            {
                using (RoleManager <IdentityRole> manager = roleFixture.CreateRoleManager(store))
                {
                    string roleNew = string.Format("TestRole_{0}", Guid.NewGuid());
                    var    role    = new IdentityRole(roleNew);
                    var    sw      = new Stopwatch();
                    sw.Start();
                    await manager.CreateAsync(role);

                    sw.Stop();

                    output.WriteLine("CreateRoleAsync: {0} seconds", sw.Elapsed.TotalSeconds);
                    Claim c1 = GenRoleClaim();
                    Claim c2 = GenRoleClaim();

                    await AddRoleClaimAsyncHelper(role, c1);
                    await AddRoleClaimAsyncHelper(role, c2);

                    await RemoveRoleClaimAsyncHelper(role, c1);
                }
            }
        }
Exemplo n.º 3
0
        public void AddRemoveRoleClaim()
        {
            using (RoleStore <IdentityRole> store = roleFixture.CreateRoleStore())
            {
                using (RoleManager <IdentityRole> manager = roleFixture.CreateRoleManager(store))
                {
                    string roleNew    = string.Format("TestRole_{0}", Guid.NewGuid());
                    var    role       = new IdentityRole(roleNew);
                    var    start      = DateTime.UtcNow;
                    var    createTask = manager.CreateAsync(role);
                    createTask.Wait();

                    output.WriteLine("CreateRoleAsync: {0} seconds", (DateTime.UtcNow - start).TotalSeconds);
                    Claim c1 = GenRoleClaim();
                    Claim c2 = GenRoleClaim();

                    AddRoleClaimHelper(role, c1);
                    AddRoleClaimHelper(role, c2);

                    RemoveRoleClaimHelper(role, c1);
                }
            }
        }