Beispiel #1
0
        public static BlogEntitiesResult UniqueEntityWithForeignEntities(
            Guid newUserId,
            Guid newChannelId,
            Guid newQueueId,
            Guid newBlogId = default(Guid))
        {
            var random  = new Random();
            var creator = UserTests.UniqueEntity(random);

            creator.Id = newUserId;

            var blog = UniqueEntity(random);

            if (newBlogId != default(Guid))
            {
                blog.Id = newBlogId;
            }

            blog.Creator   = creator;
            blog.CreatorId = creator.Id;

            var channel = ChannelTests.UniqueEntity(random);

            channel.Id     = newChannelId;
            channel.Blog   = blog;
            channel.BlogId = blog.Id;

            var queue = QueueTests.UniqueEntity(random);

            queue.Id     = newQueueId;
            queue.Blog   = blog;
            queue.BlogId = blog.Id;

            return(new BlogEntitiesResult(creator, blog, channel, queue));
        }
Beispiel #2
0
        public static Task CreateTestNoteAsync(this IFifthweekDbContext databaseContext, Guid newUserId, Guid newPostId, Random random = null)
        {
            if (random == null)
            {
                random = new Random();
            }

            var creator = UserTests.UniqueEntity(random);

            creator.Id = newUserId;

            var subscription = BlogTests.UniqueEntity(random);

            subscription.Creator   = creator;
            subscription.CreatorId = creator.Id;

            var channel = ChannelTests.UniqueEntity(random);

            channel.Blog   = subscription;
            channel.BlogId = subscription.Id;

            var post = UniqueNote(random);

            post.Id        = newPostId;
            post.Channel   = channel;
            post.ChannelId = channel.Id;

            databaseContext.Posts.Add(post);
            return(databaseContext.SaveChangesAsync());
        }
        public static async Task <IReadOnlyList <Channel> > CreateTestChannelsAsync(
            this IFifthweekDbContext databaseContext,
            Guid newUserId,
            Guid newBlogId,
            params Guid[] newChannelIds)
        {
            var creator = UserTests.UniqueEntity(Random);

            creator.Id = newUserId;

            var blog = BlogTests.UniqueEntity(Random);

            blog.Id        = newBlogId;
            blog.Creator   = creator;
            blog.CreatorId = creator.Id;

            var channels = new List <Channel>();

            foreach (var newChannelId in newChannelIds)
            {
                var channel = ChannelTests.UniqueEntity(Random);
                channel.Id     = newChannelId;
                channel.Blog   = blog;
                channel.BlogId = blog.Id;
                databaseContext.Channels.Add(channel);
                channels.Add(channel);
            }

            await databaseContext.SaveChangesAsync();

            return(channels);
        }
 private void CreateChannels(Blog blog, List <Channel> userChannels)
 {
     for (var channelIndex = 0; channelIndex < ChannelsPerSubscription; channelIndex++)
     {
         var channel = ChannelTests.UniqueEntity(Random);
         channel.Blog   = blog;
         channel.BlogId = blog.Id;
         this.channels.Add(channel);
         userChannels.Add(channel);
     }
 }