Ejemplo n.º 1
0
        public async Task DynamoRoleStore_Delete_DeletesRole()
        {
            var roleName = TestUtils.RandomString(10);
            var role     = new DynamoIdentityRole(roleName);

            using (var dbProvider = DynamoDbServerTestUtils.CreateDatabase())
            {
                var roleStore = new DynamoRoleStore <DynamoIdentityRole>();
                await roleStore.EnsureInitializedAsync(dbProvider.Client, dbProvider.Context);

                await roleStore.CreateAsync(role, CancellationToken.None);

                await Task.Delay(2000);

                role = await roleStore.FindByIdAsync(role.Id, CancellationToken.None);

                // ACT
                await roleStore.DeleteAsync(role, CancellationToken.None);

                // ASSERT
                var result = await roleStore.FindByIdAsync(role.Id, CancellationToken.None);

                Assert.Null(result);
            }
        }
Ejemplo n.º 2
0
        public async Task DynamoRoleStore_Update_UpdatesRole()
        {
            var roleName = TestUtils.RandomString(10);
            var role     = new DynamoIdentityRole(roleName);

            using (var dbProvider = DynamoDbServerTestUtils.CreateDatabase())
            {
                var roleStore = new DynamoRoleStore <DynamoIdentityRole>();
                await roleStore.EnsureInitializedAsync(dbProvider.Client, dbProvider.Context);

                await roleStore.CreateAsync(role, CancellationToken.None);

                role.AddClaim(new Claim("test", "test"));

                // ACT
                await roleStore.UpdateAsync(role, CancellationToken.None);

                // ASSERT
                var result = await roleStore.FindByIdAsync(role.Id, CancellationToken.None);

                Assert.Equal(role.Id, result.Id);
                Assert.Contains("test", result.ClaimTypes);
                Assert.Contains("test", result.ClaimValues);
            }
        }