示例#1
0
        public async Task ShouldCreateNewRoleInDatabase()
        {
            DocumentDbIdentityRole newRole = DocumentDbIdentityRoleBuilder.Create().WithId();
            DocumentDbRoleStore <DocumentDbIdentityRole> store = CreateRoleStore();

            // Create the new role
            IdentityResult result = store.CreateAsync(newRole, CancellationToken.None).Result;

            // Get it again from the DB to check if it was created correctly
            DocumentDbIdentityRole queriedRole = await store.FindByIdAsync(newRole.Id, CancellationToken.None);

            Assert.True(result.Succeeded);
            Assert.Equal(queriedRole, newRole, new DocumentDbIdentityRoleComparer());
        }
示例#2
0
        public async Task ShouldReturnRoleById()
        {
            DocumentDbRoleStore <DocumentDbIdentityRole> store = CreateRoleStore();
            DocumentDbIdentityRole targetRole = DocumentDbIdentityRoleBuilder.Create().WithId();

            // Create sample data in DB
            CreateDocument(DocumentDbIdentityRoleBuilder.Create());
            CreateDocument(DocumentDbIdentityRoleBuilder.Create());
            CreateDocument(targetRole);
            CreateDocument(DocumentDbIdentityRoleBuilder.Create());

            DocumentDbIdentityRole queriedRole = await store.FindByIdAsync(targetRole.Id, CancellationToken.None);

            Assert.Equal(targetRole.Id, queriedRole.Id);
        }
示例#3
0
        public async Task ShouldUpdateExistingRoleInDatabase()
        {
            DocumentDbRoleStore <DocumentDbIdentityRole> store = CreateRoleStore();
            DocumentDbIdentityRole existingRole = DocumentDbIdentityRoleBuilder.Create().WithId();

            // Create sample data in DB
            CreateDocument(existingRole);

            // Change property to upate on sample data and call the update mehtod
            existingRole.Name = Guid.NewGuid().ToString();
            IdentityResult result = await store.UpdateAsync(existingRole, CancellationToken.None);

            // Get it again from the DB to check if it was created correctly
            DocumentDbIdentityRole queriedRole = await store.FindByIdAsync(existingRole.Id, CancellationToken.None);

            Assert.True(result.Succeeded);
            Assert.Equal(existingRole, queriedRole, new DocumentDbIdentityRoleComparer());
        }