Example #1
0
        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);
            });
        }
Example #2
0
        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);
            });
        }
Example #3
0
        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);
            });
        }
Example #4
0
 public void InitializeTarget(IFifthweekDbConnectionFactory connectionFactory)
 {
     this.target = new IsPostOwnerDbStatement(connectionFactory);
 }