Exemple #1
0
        private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var random  = new Random();
                var creator = UserTests.UniqueEntity(random);

                var blog = BlogTests.UniqueEntity(random);
                blog.Creator   = creator;
                blog.CreatorId = creator.Id;

                var channel = ChannelTests.UniqueEntity(random);
                channel.Id     = ChannelId.Value;
                channel.Blog   = blog;
                channel.BlogId = blog.Id;

                var queue = QueueTests.UniqueEntity(random);
                queue.Id     = QueueId.Value;
                queue.Blog   = blog;
                queue.BlogId = blog.Id;

                var weeklyReleaseTimes =
                    new[] { ExistingReleaseA, ExistingReleaseB, ExistingReleaseC }.Select(
                    _ => new WeeklyReleaseTime(QueueId.Value, (byte)_.Value));

                databaseContext.Queues.Add(queue);
                await databaseContext.SaveChangesAsync();

                await databaseContext.Database.Connection.InsertAsync(weeklyReleaseTimes);
            }
        }
Exemple #2
0
        private async Task <Post> CreatePostWithIdAsync(
            TestDatabaseContext testDatabase,
            DateTime liveDate,
            bool scheduledByQueue,
            bool differentCollection,
            Guid postId)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                if (differentCollection)
                {
                    var collection = QueueTests.UniqueEntity(Random);
                    collection.Id     = DifferentQueueId.Value;
                    collection.BlogId = BlogId.Value;
                    await databaseContext.Database.Connection.InsertAsync(collection);
                }

                var post = PostTests.UniqueFileOrImage(Random);
                post.Id        = postId;
                post.ChannelId = ChannelId.Value;
                post.QueueId   = scheduledByQueue ? (differentCollection ? DifferentQueueId.Value : QueueId.Value) : (Guid?)null;
                post.LiveDate  = liveDate;
                await databaseContext.Database.Connection.InsertAsync(post);
            }

            using (var databaseContext = testDatabase.CreateContext())
            {
                return(await databaseContext.Posts.FirstAsync(_ => _.Id == postId));
            }
        }
Exemple #3
0
        private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var random  = new Random();
                var creator = UserTests.UniqueEntity(random);

                var blog = BlogTests.UniqueEntity(random);
                blog.Creator   = creator;
                blog.CreatorId = creator.Id;

                var orignalChannel = ChannelTests.UniqueEntity(random);
                orignalChannel.Id     = ChannelId.Value;
                orignalChannel.Blog   = blog;
                orignalChannel.BlogId = blog.Id;

                var collection = QueueTests.UniqueEntity(random);
                collection.Id     = QueueId.Value;
                collection.Blog   = blog;
                collection.BlogId = blog.Id;

                databaseContext.Queues.Add(collection);
                await databaseContext.SaveChangesAsync();
            }
        }
        private async Task CreateQueuedPostsForAnotherCollectionAsync(TestDatabaseContext testDatabase)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var userId    = Guid.NewGuid();
                var channelId = Guid.NewGuid();
                var entities  = await databaseContext.CreateTestEntitiesAsync(userId, channelId, QueueId.Value);

                var otherQueue = QueueTests.UniqueEntity(Random);
                otherQueue.BlogId = entities.Blog.Id;
                await databaseContext.Database.Connection.InsertAsync(otherQueue);

                var posts = new List <Post>();

                for (var i = 0; i < PostCount; i++)
                {
                    var post = PostTests.UniqueFileOrImage(Random);
                    post.ChannelId = channelId;
                    post.QueueId   = otherQueue.Id;
                    post.LiveDate  = Now.AddDays(1);
                    posts.Add(post);
                }

                await databaseContext.Database.Connection.InsertAsync(posts);
            }
        }
        public static void Main()
        {
            var networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];

            if (!networkInterface.IsDhcpEnabled || !networkInterface.IsDynamicDnsEnabled)
            {
                networkInterface.EnableDhcp();
                networkInterface.EnableDynamicDns();
                networkInterface.RenewDhcpLease();

                Debug.Print("Interface set to " + networkInterface.IPAddress);
            }

            if (DateTime.Now < new DateTime(2012, 01, 01))
            {
                var networkTime = NtpClient.GetNetworkTime();
                Utility.SetLocalTime(networkTime);
            }

            var queueTests = new QueueTests(AccountName, AccountKey);

            queueTests.Run();

            var tableTests = new TableTests(AccountName, AccountKey);

            tableTests.Run();
        }
        private async Task <IReadOnlyList <Post> > CreatePostsAsync(
            TestDatabaseContext testDatabase,
            QueueId queueId,
            IReadOnlyList <DateTime> liveDates,
            bool scheduledByQueue)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var user = UserTests.UniqueEntity(Random);
                await databaseContext.Database.Connection.InsertAsync(user);

                var file = FileTests.UniqueEntity(Random);
                file.UserId = user.Id;
                await databaseContext.Database.Connection.InsertAsync(file);

                var blog = BlogTests.UniqueEntity(Random);
                blog.CreatorId = user.Id;
                await databaseContext.Database.Connection.InsertAsync(blog);

                var channel = ChannelTests.UniqueEntity(Random);
                channel.BlogId = blog.Id;
                await databaseContext.Database.Connection.InsertAsync(channel);

                var collection = QueueTests.UniqueEntity(Random);
                collection.Id     = queueId.Value;
                collection.BlogId = blog.Id;
                await databaseContext.Database.Connection.InsertAsync(collection);

                var postsInCollection = new List <Post>();
                foreach (var liveDate in liveDates)
                {
                    var post = PostTests.UniqueNote(Random);
                    post.ChannelId = channel.Id;
                    post.QueueId   = scheduledByQueue ? queueId.Value : (Guid?)null;
                    post.LiveDate  = liveDate;

                    // Clip dates as we will be comparing from these entities.
                    post.LiveDate     = new SqlDateTime(post.LiveDate).Value;
                    post.CreationDate = new SqlDateTime(post.CreationDate).Value;

                    postsInCollection.Add(post);
                }

                await databaseContext.Database.Connection.InsertAsync(postsInCollection);

                return(postsInCollection);
            }
        }
Exemple #7
0
        private async Task CreatePostAsync(TestDatabaseContext testDatabase, DateTime liveDate, bool scheduledByQueue, bool differentCollection)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                if (differentCollection)
                {
                    var collection = QueueTests.UniqueEntity(Random);
                    collection.Id     = DifferentQueueId.Value;
                    collection.BlogId = BlogId.Value;
                    await databaseContext.Database.Connection.InsertAsync(collection);
                }

                var post = PostTests.UniqueFileOrImage(Random);
                post.ChannelId      = ChannelId.Value;
                post.QueueId        = scheduledByQueue ? (differentCollection ? DifferentQueueId.Value : QueueId.Value) : (Guid?)null;
                post.PreviewImageId = FileId.Value; // Reuse same file across each post. Not realistic, but doesn't matter for this test.
                post.LiveDate       = liveDate;
                await databaseContext.Database.Connection.InsertAsync(post);
            }
        }
        private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase, bool createLivePosts, bool createFuturePosts)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                await this.CreateUserAsync(databaseContext, UnsubscribedUserId);

                await this.CreateUserAsync(databaseContext, SubscribedUserId);

                await this.CreateUserAsync(databaseContext, GuestListUserId);

                var channelSubscriptions      = new List <ChannelSubscription>();
                var calculatedAccountBalances = new List <CalculatedAccountBalance>();
                var freeAccessUsers           = new List <FreeAccessUser>();

                var channels        = new List <ChannelId>();
                var queues          = new List <QueueId>();
                var files           = new List <FileId>();
                var images          = new List <FileId>();
                var channelEntities = new List <Channel>();
                var queueEntities   = new List <Queue>();
                var postEntities    = new List <Post>();
                var origins         = new List <UserPaymentOrigin>();
                var likes           = new List <Like>();
                var comments        = new List <Persistence.Comment>();

                if (createLivePosts || createFuturePosts)
                {
                    channelSubscriptions.Add(new ChannelSubscription(ChannelIds[0].Value, null, SubscribedUserId.Value, null, ChannelPrice, Now, Now));
                    channelSubscriptions.Add(new ChannelSubscription(ChannelIds[1].Value, null, SubscribedUserId.Value, null, ChannelPrice, Now, Now));
                    calculatedAccountBalances.Add(new CalculatedAccountBalance(SubscribedUserId.Value, LedgerAccountType.FifthweekCredit, Now, 10));
                    calculatedAccountBalances.Add(new CalculatedAccountBalance(SubscribedUserId.Value, LedgerAccountType.FifthweekCredit, Now.AddDays(-1), 0));

                    channelSubscriptions.Add(new ChannelSubscription(ChannelIds[0].Value, null, GuestListUserId.Value, null, 0, Now, Now));
                    channelSubscriptions.Add(new ChannelSubscription(ChannelIds[1].Value, null, GuestListUserId.Value, null, 0, Now, Now));

                    freeAccessUsers.Add(new FreeAccessUser(BlogId.Value, GuestListUserId.Value + "@test.com"));

                    foreach (var newsfeedPost in SortedNewsfeedPosts)
                    {
                        if (createLivePosts && !createFuturePosts && newsfeedPost.LiveDate > Now)
                        {
                            continue;
                        }

                        if (!createLivePosts && createFuturePosts && newsfeedPost.LiveDate <= Now)
                        {
                            continue;
                        }

                        if (newsfeedPost.ImageId != null)
                        {
                            images.Add(newsfeedPost.ImageId);
                        }

                        if (!channels.Contains(newsfeedPost.ChannelId))
                        {
                            channels.Add(newsfeedPost.ChannelId);
                        }

                        postEntities.Add(new Post(
                                             newsfeedPost.PostId.Value,
                                             newsfeedPost.ChannelId.Value,
                                             null,
                                             (Guid?)null,
                                             null,
                                             newsfeedPost.ImageId == null ? (Guid?)null : newsfeedPost.ImageId.Value,
                                             null,
                                             newsfeedPost.PreviewText == null ? null : newsfeedPost.PreviewText.Value,
                                             "content",
                                             newsfeedPost.PreviewWordCount,
                                             newsfeedPost.WordCount,
                                             newsfeedPost.ImageCount,
                                             newsfeedPost.FileCount,
                                             newsfeedPost.VideoCount,
                                             newsfeedPost.LiveDate,
                                             newsfeedPost.CreationDate));

                        for (int i = 0; i < newsfeedPost.LikesCount; i++)
                        {
                            likes.Add(
                                new Like(
                                    newsfeedPost.PostId.Value,
                                    null,
                                    UserIds[i].Value,
                                    null,
                                    DateTime.UtcNow));
                        }

                        for (int i = 0; i < newsfeedPost.CommentsCount; i++)
                        {
                            comments.Add(
                                new Persistence.Comment(
                                    Guid.NewGuid(),
                                    newsfeedPost.PostId.Value,
                                    null,
                                    UserIds[i].Value,
                                    null,
                                    "Comment " + this.random.Next(),
                                    DateTime.UtcNow));
                        }
                    }
                }

                foreach (var channelId in channels)
                {
                    var channel = ChannelTests.UniqueEntity(Random);
                    channel.Id     = channelId.Value;
                    channel.BlogId = BlogId.Value;
                    channel.Price  = ChannelPrice;

                    channelEntities.Add(channel);
                }

                foreach (var queueId in queues)
                {
                    var queue = QueueTests.UniqueEntity(Random);
                    queue.Id     = queueId.Value;
                    queue.BlogId = BlogId.Value;

                    queueEntities.Add(queue);
                }

                var fileEntities = files.Select(fileId =>
                {
                    var file    = FileTests.UniqueEntity(Random);
                    file.Id     = fileId.Value;
                    file.UserId = CreatorId.Value;
                    file.FileNameWithoutExtension = FileName;
                    file.FileExtension            = FileExtension;
                    file.BlobSizeBytes            = FileSize;
                    return(file);
                });

                var imageEntities = images.Select(fileId =>
                {
                    var file    = FileTests.UniqueEntity(Random);
                    file.Id     = fileId.Value;
                    file.UserId = CreatorId.Value;
                    file.FileNameWithoutExtension = FileName;
                    file.FileExtension            = FileExtension;
                    file.BlobSizeBytes            = FileSize;
                    file.RenderWidth  = FileWidth;
                    file.RenderHeight = FileHeight;
                    return(file);
                });

                await databaseContext.CreateTestBlogAsync(CreatorId.Value, BlogId.Value, null, Random);

                await databaseContext.Database.Connection.InsertAsync(channelEntities);

                await databaseContext.Database.Connection.InsertAsync(queueEntities);

                await databaseContext.Database.Connection.InsertAsync(fileEntities);

                await databaseContext.Database.Connection.InsertAsync(imageEntities);

                await databaseContext.Database.Connection.InsertAsync(postEntities);

                await databaseContext.Database.Connection.InsertAsync(channelSubscriptions);

                await databaseContext.Database.Connection.InsertAsync(calculatedAccountBalances);

                await databaseContext.Database.Connection.InsertAsync(freeAccessUsers);

                await databaseContext.Database.Connection.InsertAsync(origins);

                await databaseContext.Database.Connection.InsertAsync(likes);

                await databaseContext.Database.Connection.InsertAsync(comments);
            }
        }
Exemple #9
0
        private async Task <IEnumerable <IIdentityEquatable> > AddUser(DbConnection connection, Random random, UserId userId, DateTime registrationDate, bool isTestUser, UserId subscriberId = null, ChannelId subscribedToId = null)
        {
            var users = new List <FifthweekUser>();
            var user  = UserTests.UniqueEntity(random);

            user.Id = userId.Value;
            user.RegistrationDate = registrationDate;
            users.Add(user);
            await connection.InsertAsync(users, false);

            var userRoles = new List <FifthweekUserRole>();

            userRoles.Add(new FifthweekUserRole(FifthweekRole.CreatorId, user.Id));
            if (isTestUser)
            {
                userRoles.Add(new FifthweekUserRole(FifthweekRole.TestUserId, user.Id));
            }
            await connection.InsertAsync(userRoles, false);

            var blogs = new List <Blog>();
            var blog  = BlogTests.UniqueEntity(random);

            blog.CreatorId = userId.Value;
            blogs.Add(blog);
            await connection.InsertAsync(blogs);

            var channels = new List <Channel>();
            var channel  = ChannelTests.UniqueEntity(random);

            channel.BlogId = blog.Id;
            channels.Add(channel);
            await connection.InsertAsync(channels);

            var queues = new List <Queue>();
            var queue  = QueueTests.UniqueEntity(random);

            queue.BlogId = blog.Id;
            queues.Add(queue);
            await connection.InsertAsync(queues);

            var files = new List <File>();
            var file  = FileTests.UniqueEntity(random);

            file.ChannelId = channel.Id;
            file.UserId    = userId.Value;
            files.Add(file);
            await connection.InsertAsync(files);

            var posts = new List <Post>();
            var post  = PostTests.UniqueFileOrImage(random);

            post.ChannelId      = channel.Id;
            post.PreviewImageId = file.Id;
            post.ChannelId      = channel.Id;
            posts.Add(post);
            await connection.InsertAsync(posts);

            var postFiles = new List <PostFile>();

            postFiles.Add(new PostFile(post.Id, file.Id));
            await connection.InsertAsync(postFiles);

            var channelSubscriptions = new List <ChannelSubscription>();

            if (subscriberId != null)
            {
                channelSubscriptions.Add(new ChannelSubscription(channel.Id, null, subscriberId.Value, null, 100, Now, Now));
                await connection.InsertAsync(channelSubscriptions);
            }
            if (subscribedToId != null)
            {
                channelSubscriptions.Add(new ChannelSubscription(subscribedToId.Value, null, userId.Value, null, 100, Now, Now));
                await connection.InsertAsync(channelSubscriptions);
            }

            var calculatedAccountBalances = new List <CalculatedAccountBalance>
            {
                new CalculatedAccountBalance(user.Id, LedgerAccountType.FifthweekCredit, Now),
            };
            await connection.InsertAsync(calculatedAccountBalances);

            var subscriberSnapshots = new List <SubscriberSnapshot>
            {
                new SubscriberSnapshot(Now, user.Id, "email"),
            };
            await connection.InsertAsync(subscriberSnapshots);

            var subscriberChannelSnapshots = new List <SubscriberChannelsSnapshot>
            {
                new SubscriberChannelsSnapshot(Guid.NewGuid(), Now, user.Id),
            };
            await connection.InsertAsync(subscriberChannelSnapshots);

            var subscriberChannelSnapshotItems = new List <SubscriberChannelsSnapshotItem>
            {
                new SubscriberChannelsSnapshotItem(subscriberChannelSnapshots[0].Id, null, channel.Id, user.Id, 100, Now),
            };
            await connection.InsertAsync(subscriberChannelSnapshotItems);

            var creatorChannelSnapshots = new List <CreatorChannelsSnapshot>
            {
                new CreatorChannelsSnapshot(Guid.NewGuid(), Now, user.Id),
            };
            await connection.InsertAsync(creatorChannelSnapshots);

            var creatorChannelSnapshotItems = new List <CreatorChannelsSnapshotItem>
            {
                new CreatorChannelsSnapshotItem(creatorChannelSnapshots[0].Id, null, channel.Id, 100),
            };
            await connection.InsertAsync(creatorChannelSnapshotItems);

            var creatorFreeAccessUsersSnapshots = new List <CreatorFreeAccessUsersSnapshot>
            {
                new CreatorFreeAccessUsersSnapshot(Guid.NewGuid(), Now, user.Id),
            };
            await connection.InsertAsync(creatorFreeAccessUsersSnapshots);

            var creatorFreeAccessUsersSnapshotItems = new List <CreatorFreeAccessUsersSnapshotItem>
            {
                new CreatorFreeAccessUsersSnapshotItem(creatorFreeAccessUsersSnapshots[0].Id, null, "email"),
            };
            await connection.InsertAsync(creatorFreeAccessUsersSnapshotItems);

            var userPaymentOrigins = new List <UserPaymentOrigin>
            {
                new UserPaymentOrigin(userId.Value, null, "paymentOriginKey", PaymentOriginKeyType.Stripe, null, null, null, null, PaymentStatus.None),
            };
            await connection.InsertAsync(userPaymentOrigins);

            return(users.Cast <IIdentityEquatable>()
                   .Concat(userRoles)
                   .Concat(blogs)
                   .Concat(channels)
                   .Concat(queues)
                   .Concat(files)
                   .Concat(posts)
                   .Concat(channelSubscriptions)
                   .Concat(calculatedAccountBalances)
                   .Concat(subscriberSnapshots)
                   .Concat(subscriberChannelSnapshots)
                   .Concat(subscriberChannelSnapshotItems)
                   .Concat(creatorChannelSnapshots)
                   .Concat(creatorChannelSnapshotItems)
                   .Concat(creatorFreeAccessUsersSnapshots)
                   .Concat(creatorFreeAccessUsersSnapshotItems)
                   .Concat(userPaymentOrigins)
                   .Concat(postFiles));
        }
        private async Task <IReadOnlyList <Post> > CreatePostsAsync(
            TestDatabaseContext testDatabase,
            UserId userId,
            QueueId queueId,
            bool liveDateInFuture,
            bool scheduledByQueue)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var user = UserTests.UniqueEntity(Random);
                user.Id = userId.Value;
                await databaseContext.Database.Connection.InsertAsync(user);

                var file = FileTests.UniqueEntity(Random);
                file.Id     = FileId.Value;
                file.UserId = user.Id;
                await databaseContext.Database.Connection.InsertAsync(file);

                var blog = BlogTests.UniqueEntity(Random);
                blog.CreatorId = user.Id;
                await databaseContext.Database.Connection.InsertAsync(blog);

                var channel = ChannelTests.UniqueEntity(Random);
                channel.BlogId = blog.Id;
                await databaseContext.Database.Connection.InsertAsync(channel);

                var queue = QueueTests.UniqueEntity(Random);
                queue.Id     = queueId.Value;
                queue.BlogId = blog.Id;
                await databaseContext.Database.Connection.InsertAsync(queue);

                var notes = new List <Post>();
                for (var i = 0; i < CollectionTotal; i++)
                {
                    // Notes are not covered by this feature as they do not belong in a collection, but we add them to create a more realistic test state.
                    var post = PostTests.UniqueNote(Random);
                    post.ChannelId = channel.Id;

                    notes.Add(post);
                }

                var postsInCollection = new List <Post>();
                for (var i = 0; i < CollectionTotal; i++)
                {
                    var post = PostTests.UniqueFileOrImage(Random);
                    post.ChannelId      = channel.Id;
                    post.QueueId        = scheduledByQueue ? queueId.Value : (Guid?)null;
                    post.PreviewImageId = file.Id;
                    post.LiveDate       = Now.AddDays((1 + Random.Next(100)) * (liveDateInFuture ? 1 : -1));

                    // Clip dates as we will be comparing from these entities.
                    post.LiveDate     = new SqlDateTime(post.LiveDate).Value;
                    post.CreationDate = new SqlDateTime(post.CreationDate).Value;

                    postsInCollection.Add(post);
                }

                await databaseContext.Database.Connection.InsertAsync(notes.Concat(postsInCollection));

                return(postsInCollection);
            }
        }
        private async Task CreateEntitiesAsync(TestDatabaseContext testDatabase, bool createLivePosts, bool createFuturePosts)
        {
            using (var databaseContext = testDatabase.CreateContext())
            {
                var channels        = new List <ChannelId>();
                var queues          = new List <QueueId>();
                var files           = new List <FileId>();
                var images          = new List <FileId>();
                var channelEntities = new List <Channel>();
                var queueEntities   = new List <Queue>();
                var postEntities    = new List <Post>();

                if (createLivePosts)
                {
                    var channelId = new ChannelId(Guid.NewGuid());
                    var queueId   = new QueueId(Guid.NewGuid());
                    channels.Add(channelId);
                    queues.Add(queueId);
                    for (var i = 1; i <= 10; i++)
                    {
                        var post = PostTests.UniqueFileOrImage(Random);
                        post.ChannelId = channelId.Value;
                        post.QueueId   = queueId.Value;
                        post.LiveDate  = DateTime.UtcNow.AddDays(i * -1);
                        postEntities.Add(post);
                    }
                }

                if (createFuturePosts)
                {
                    foreach (var backlogPost in SortedBacklogPosts)
                    {
                        if (backlogPost.ImageId != null)
                        {
                            images.Add(backlogPost.ImageId);
                        }

                        if (!channels.Contains(backlogPost.ChannelId))
                        {
                            channels.Add(backlogPost.ChannelId);
                        }

                        if (backlogPost.QueueId != null)
                        {
                            queues.Add(backlogPost.QueueId);
                        }

                        postEntities.Add(new Post(
                                             backlogPost.PostId.Value,
                                             backlogPost.ChannelId.Value,
                                             null,
                                             backlogPost.QueueId == null ? (Guid?)null : backlogPost.QueueId.Value,
                                             null,
                                             backlogPost.ImageId == null ? (Guid?)null : backlogPost.ImageId.Value,
                                             null,
                                             backlogPost.PreviewText == null ? null : backlogPost.PreviewText.Value,
                                             "content",
                                             backlogPost.PreviewWordCount,
                                             backlogPost.WordCount,
                                             backlogPost.ImageCount,
                                             backlogPost.FileCount,
                                             backlogPost.VideoCount,
                                             backlogPost.LiveDate,
                                             backlogPost.CreationDate));
                    }
                }

                foreach (var channelId in channels)
                {
                    var channel = ChannelTests.UniqueEntity(Random);
                    channel.Id     = channelId.Value;
                    channel.BlogId = BlogId.Value;

                    channelEntities.Add(channel);
                }

                foreach (var queueId in queues)
                {
                    var queue = QueueTests.UniqueEntity(Random);
                    queue.Id     = queueId.Value;
                    queue.BlogId = BlogId.Value;

                    queueEntities.Add(queue);
                }

                var fileEntities = files.Select(fileId =>
                {
                    var file    = FileTests.UniqueEntity(Random);
                    file.Id     = fileId.Value;
                    file.UserId = UserId.Value;
                    file.FileNameWithoutExtension = FileName;
                    file.FileExtension            = FileExtension;
                    file.BlobSizeBytes            = FileSize;
                    return(file);
                });

                var imageEntities = images.Select(fileId =>
                {
                    var file    = FileTests.UniqueEntity(Random);
                    file.Id     = fileId.Value;
                    file.UserId = UserId.Value;
                    file.FileNameWithoutExtension = FileName;
                    file.FileExtension            = FileExtension;
                    file.BlobSizeBytes            = FileSize;
                    file.RenderWidth  = FileWidth;
                    file.RenderHeight = FileHeight;
                    return(file);
                });
                await databaseContext.CreateTestBlogAsync(UserId.Value, BlogId.Value);

                await databaseContext.Database.Connection.InsertAsync(channelEntities);

                await databaseContext.Database.Connection.InsertAsync(queueEntities);

                await databaseContext.Database.Connection.InsertAsync(fileEntities);

                await databaseContext.Database.Connection.InsertAsync(imageEntities);

                await databaseContext.Database.Connection.InsertAsync(postEntities);
            }
        }
        private async Task CreateChannelsAndQueuesAsync(TestDatabaseContext testDatabase)
        {
            var random = new Random();

            var channel1 = ChannelTests.UniqueEntity(random);

            channel1.Id = ChannelId1.Value;
            ConfigureChannel(channel1);

            var channel2 = ChannelTests.UniqueEntity(random);

            channel2.Id = ChannelId2.Value;
            ConfigureChannel(channel2);

            var channel3 = ChannelTests.UniqueEntity(random);

            channel3.Id = ChannelId3.Value;
            ConfigureChannel(channel3);

            var queue1 = QueueTests.UniqueEntity(random);

            queue1.Id = QueueId1.Value;
            ConfigureQueue(queue1);

            var queue2 = QueueTests.UniqueEntity(random);

            queue2.Id = QueueId2.Value;
            ConfigureQueue(queue2);

            var queue3 = QueueTests.UniqueEntity(random);

            queue3.Id = QueueId3.Value;
            ConfigureQueue(queue3);

            var wrt1  = WeeklyReleaseTimeTests.UniqueEntity(random, queue1.Id);
            var wrt2a = WeeklyReleaseTimeTests.UniqueEntity(random, queue2.Id);
            var wrt2b = WeeklyReleaseTimeTests.UniqueEntity(random, queue2.Id);
            var wrt3a = WeeklyReleaseTimeTests.UniqueEntity(random, queue3.Id);
            var wrt3b = WeeklyReleaseTimeTests.UniqueEntity(random, queue3.Id);
            var wrt3c = WeeklyReleaseTimeTests.UniqueEntity(random, queue3.Id);

            using (var connection = testDatabase.CreateConnection())
            {
                await connection.InsertAsync(channel1);

                await connection.InsertAsync(channel2);

                await connection.InsertAsync(channel3);

                await connection.InsertAsync(queue1);

                await connection.InsertAsync(queue2);

                await connection.InsertAsync(queue3);

                await connection.InsertAsync(wrt1);

                await connection.InsertAsync(wrt2a);

                await connection.InsertAsync(wrt2b);

                await connection.InsertAsync(wrt3a);

                await connection.InsertAsync(wrt3b);

                await connection.InsertAsync(wrt3c);
            }
        }