Beispiel #1
0
        public async Task CanCreateUsingAddRoleManager()
        {
            var manager = TestIdentityFactory.CreateRoleManager();

            Assert.NotNull(manager);
            IdentityResultAssert.IsSuccess(await manager.CreateAsync(new IdentityRole("arole")));
        }
Beispiel #2
0
        public async Task CanSetUserName()
        {
            var manager = TestIdentityFactory.CreateRoleManager();
            var role    = new IdentityRole("UpdateRoleName");

            IdentityResultAssert.IsSuccess(await manager.CreateAsync(role));
            Assert.Null(await manager.FindByNameAsync("New"));
            IdentityResultAssert.IsSuccess(await manager.SetRoleNameAsync(role, "New"));
            Assert.NotNull(await manager.FindByNameAsync("New"));
            Assert.Null(await manager.FindByNameAsync("UpdateAsync"));
        }
Beispiel #3
0
        public async Task CanCreateRoleWithSingletonManager()
        {
            var services = TestIdentityFactory.CreateTestServices();

            services.AddEntityFramework().AddInMemoryStore();
            services.AddTransient <InMemoryContext>();
            services.AddTransient <IRoleStore <IdentityRole>, RoleStore <IdentityRole, InMemoryContext> >();
            services.AddSingleton <RoleManager <IdentityRole> >();
            var provider = services.BuildServiceProvider();
            var manager  = provider.GetRequiredService <RoleManager <IdentityRole> >();

            Assert.NotNull(manager);
            IdentityResultAssert.IsSuccess(await manager.CreateAsync(new IdentityRole("someRole")));
        }