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()); }
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); }
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()); }