Example #1
0
        public void GetArticleListAsync_ArticlesExist_ShouldCreateNewContext(string firstArticleName, string secondArticleName, string thirdArticleName)
        {
            //Arrange
            var data = new List <Article>()
            {
                new Article {
                    Name = firstArticleName
                },
                new Article {
                    Name = secondArticleName
                },
                new Article {
                    Name = thirdArticleName
                },
            };

            PrepareMocks(data);

            var expectedResult = new List <ArticleHeader>()
            {
                new ArticleHeader {
                    Name = firstArticleName
                },
                new ArticleHeader {
                    Name = secondArticleName
                },
                new ArticleHeader {
                    Name = thirdArticleName
                },
            };

            //Act
            var result = articlesAccess.GetArticleListAsync().Result;

            //Assert
            result.Should().BeEquivalentTo(expectedResult);
        }
Example #2
0
        public async Task <MessageResponse <List <ArticleHeader> > > GetArticlesListAsync()
        {
            var articlesList = await articlesAccess.GetArticleListAsync();

            return(new MessageResponse <List <ArticleHeader> >()
            {
                Message = articlesList.Select(x => new ArticleHeader()
                {
                    Name = x.Name,
                    Author = x.Author,
                    TimeCreated = x.TimeCreated,
                    TimeModified = x.TimeModified
                }).ToList()
            });
        }