public async Task WhenCheckingPostOwnership_ItShouldFailIfNoPostsMatchCreator() { await this.DatabaseTestAsync(async testDatabase => { this.target = new IsPostOwnerDbStatement(testDatabase); await this.CreatePostAsync(new UserId(Guid.NewGuid()), PostId, testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(UserId, PostId); Assert.IsFalse(result); return(ExpectedSideEffects.None); }); }
public async Task WhenCheckingPostOwnership_ItShouldPassIfAtThePostBelongsToTheUser() { await this.DatabaseTestAsync(async testDatabase => { this.target = new IsPostOwnerDbStatement(testDatabase); await this.CreatePostAsync(UserId, PostId, testDatabase); await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(UserId, PostId); Assert.IsTrue(result); return(ExpectedSideEffects.None); }); }
public async Task WhenCheckingPostOwnership_ItShouldFailIfNoPostsExist() { await this.DatabaseTestAsync(async testDatabase => { this.target = new IsPostOwnerDbStatement(testDatabase); using (var databaseContext = testDatabase.CreateContext()) { await databaseContext.Database.Connection.ExecuteAsync("DELETE FROM Likes;DELETE FROM Comments;DELETE FROM Posts"); } await testDatabase.TakeSnapshotAsync(); var result = await this.target.ExecuteAsync(UserId, PostId); Assert.IsFalse(result); return(ExpectedSideEffects.None); }); }
public void InitializeTarget(IFifthweekDbConnectionFactory connectionFactory) { this.target = new IsPostOwnerDbStatement(connectionFactory); }