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); }
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 <FifthweekUser> CreateTestUserAsync(this IFifthweekDbContext databaseContext, Guid newUserId, Random random = null) { random = random ?? new Random(); var creator = UserTests.UniqueEntity(random); creator.Id = newUserId; databaseContext.Users.Add(creator); await databaseContext.SaveChangesAsync(); return(creator); }
public static async Task <BlogEntitiesResult> CreateTestEntitiesAsync( this IFifthweekDbContext databaseContext, Guid newUserId, Guid newChannelId, Guid newCollectionId, Guid newBlogId = default(Guid)) { var entites = UniqueEntityWithForeignEntities(newUserId, newChannelId, newCollectionId, newBlogId); databaseContext.Channels.Add(entites.Channel); databaseContext.Queues.Add(entites.Queue); await databaseContext.SaveChangesAsync(); return(entites); }
public static Task CreateTestBlogAsync(this IFifthweekDbContext databaseContext, Guid newUserId, Guid newBlogId, Guid?headerImageFileId = null, Random random = null, string username = null, string blogName = null) { if (random == null) { random = new Random(); } var creator = UserTests.UniqueEntity(random); creator.Id = newUserId; if (username != null) { creator.UserName = username; } var blog = UniqueEntity(random); blog.Id = newBlogId; blog.Creator = creator; blog.CreatorId = creator.Id; if (blogName != null) { blog.Name = blogName; } if (headerImageFileId.HasValue) { var file = FileTests.UniqueEntity(random); file.Id = headerImageFileId.Value; file.UserId = creator.Id; blog.HeaderImageFile = file; blog.HeaderImageFileId = file.Id; } databaseContext.Blogs.Add(blog); return(databaseContext.SaveChangesAsync()); }