public async Task WhenCheckingBlogOwnership_ItShouldFailIfNoBlogsMatchCreator()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new BlogOwnership(testDatabase);
                await this.CreateBlogAsync(new UserId(Guid.NewGuid()), BlogId, testDatabase);
                await testDatabase.TakeSnapshotAsync();

                var result = await this.target.IsOwnerAsync(UserId, BlogId);

                Assert.IsFalse(result);
                return(ExpectedSideEffects.None);
            });
        }
        public async Task WhenCheckingBlogOwnership_ItShouldPassIfAtLeastOneBlogMatchesBlogAndCreator()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new BlogOwnership(testDatabase);
                await this.CreateBlogAsync(UserId, BlogId, testDatabase);
                await testDatabase.TakeSnapshotAsync();

                var result = await this.target.IsOwnerAsync(UserId, BlogId);

                Assert.IsTrue(result);
                return(ExpectedSideEffects.None);
            });
        }
        public async Task WhenCheckingBlogOwnership_ItShouldFailIfNoBlogsExist()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.target = new BlogOwnership(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 Blogs");
                }

                await testDatabase.TakeSnapshotAsync();

                var result = await this.target.IsOwnerAsync(UserId, BlogId);

                Assert.IsFalse(result);
                return(ExpectedSideEffects.None);
            });
        }