public async Task WhenCheckingCollectionOwnership_ItShouldFailIfNoCollectionsMatchCreator() { await this.DatabaseTestAsync(async testDatabase => { this.target = new QueueOwnership(testDatabase); await this.CreateCollectionAsync(new UserId(Guid.NewGuid()), QueueId, testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.IsOwnerAsync(UserId, QueueId); Assert.IsFalse(result); return(ExpectedSideEffects.None); }); }
public async Task WhenCheckingCollectionOwnership_ItShouldPassIfAtLeastOneCollectionMatchesCollectionAndCreator() { await this.DatabaseTestAsync(async testDatabase => { this.target = new QueueOwnership(testDatabase); await this.CreateCollectionAsync(UserId, QueueId, testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.IsOwnerAsync(UserId, QueueId); Assert.IsTrue(result); return(ExpectedSideEffects.None); }); }
public async Task WhenCheckingCollectionOwnership_ItShouldFailIfNoCollectionsExist() { await this.DatabaseTestAsync(async testDatabase => { this.target = new QueueOwnership(testDatabase); using (var databaseContext = testDatabase.CreateContext()) { await databaseContext.Database.Connection.ExecuteAsync("UPDATE Posts SET QueueId=NULL"); await databaseContext.Database.Connection.ExecuteAsync("DELETE FROM Queues"); } await testDatabase.TakeSnapshotAsync(); var result = await this.target.IsOwnerAsync(UserId, QueueId); Assert.IsFalse(result); return(ExpectedSideEffects.None); }); }