示例#1
0
        public async Task TestGetCountOnAllArticlesMethod()
        {
            var context           = ApplicationDbContextInMemoryFactory.InitializeContext();
            var articleRepository = new EfDeletableEntityRepository <Article>(context);

            var articlesService = new ArticlesService(articleRepository);

            for (int i = 0; i < 10; i++)
            {
                var inputModel = new CreateArticleViewModel
                {
                    ImgUrl  = $"TT{i}{i * 2}asd",
                    Content = $"Ten{i}{i * 2}",
                    Title   = $"Article{i}",
                };
                await articlesService.CreateAsync(inputModel, i.ToString());
            }

            var result = articlesService.GetCountOnAllArticles();

            Assert.Equal(10, result);
        }