Example #1
0
        private static IDictionary <int, Article> Seed(AuthorService authorService)
        {
            var authorIds = authorService.GetAll().Select(author => author.Id);

            var articleFaker = new Faker <Article>()
                               .CustomInstantiator(faker =>
                                                   new Article(
                                                       faker.IndexFaker + 1,
                                                       faker.PickRandom(authorIds),
                                                       faker.Lorem.Sentence().TrimEnd('.'),
                                                       faker.Lorem.Paragraphs()));

            return(articleFaker.Generate(5 * authorIds.Count())
                   .ToDictionary(article => article.Id));
        }
Example #2
0
        private static IDictionary <int, Comment> Seed(AuthorService authorService, ArticleService articleService)
        {
            var authorIds  = authorService.GetAll().Select(author => author.Id);
            var articleIds = articleService.GetAll().Select(article => article.Id);

            var commentFaker = new Faker <Comment>()
                               .CustomInstantiator(faker =>
                                                   new Comment(
                                                       faker.IndexFaker + 1,
                                                       faker.PickRandom(authorIds),
                                                       faker.PickRandom(articleIds),
                                                       faker.Lorem.Sentence()));

            return(commentFaker.Generate(5 * articleIds.Count())
                   .ToDictionary(comment => comment.Id));
        }