public async Task WhenCheckingChannelOwnership_ItShouldFailIfNoChannelsMatchCreator() { await this.DatabaseTestAsync(async testDatabase => { this.target = new ChannelOwnership(testDatabase); await this.CreateChannelAsync(new UserId(Guid.NewGuid()), ChannelId, testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.IsOwnerAsync(UserId, ChannelId); Assert.IsFalse(result); return(ExpectedSideEffects.None); }); }
public async Task WhenCheckingChannelOwnership_ItShouldPassIfAtLeastOneChannelMatchesChannelAndCreator() { await this.DatabaseTestAsync(async testDatabase => { this.target = new ChannelOwnership(testDatabase); await this.CreateChannelAsync(UserId, ChannelId, testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.IsOwnerAsync(UserId, ChannelId); Assert.IsTrue(result); return(ExpectedSideEffects.None); }); }
public async Task WhenCheckingChannelOwnership_ItShouldFailIfNoChannelsExist() { await this.DatabaseTestAsync(async testDatabase => { this.target = new ChannelOwnership(testDatabase); using (var databaseContext = testDatabase.CreateContext()) { // We must delete ChannelSubscriptions first as there isn't a cascade delete setup // due to multiple cascade branches. await databaseContext.Database.Connection.ExecuteAsync("DELETE FROM Likes;DELETE FROM Comments;DELETE FROM ChannelSubscriptions;DELETE FROM Channels"); } await testDatabase.TakeSnapshotAsync(); var result = await this.target.IsOwnerAsync(UserId, ChannelId); Assert.IsFalse(result); return(ExpectedSideEffects.None); }); }