コード例 #1
0
        public async Task TestGetArticlesByPageMethod()
        {
            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 result1 = articlesService.GetArticlesByPage <IndexArticleViewModel>(5, 5);
            var result2 = articlesService.GetArticlesByPage <IndexArticleViewModel>(5, 0);

            Assert.Equal(5, result2.Count());

            Assert.Equal(5, result1.Count());
        }