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 CreateBlogs(FifthweekUser creator) { var userBlogs = new List <Blog>(); var userChannels = new List <Channel>(); var userQueues = new List <Queue>(); for (var blogIndex = 0; blogIndex < BlogsPerCreator; blogIndex++) { var blog = BlogTests.UniqueEntity(Random); if (blog.HeaderImageFile != null) { var file = blog.HeaderImageFile; file.UserId = creator.Id; this.files.Add(file); } blog.Creator = creator; blog.CreatorId = creator.Id; userBlogs.Add(blog); this.blogs.Add(blog); this.CreateChannels(blog, userChannels); this.CreateQueues(blog, userQueues); this.CreatePosts(blog, userChannels, userQueues); } }