Пример #1
0
        public async Task GetArticlesGroupsByDateAsync_ReturnCountOfArticlesGroupedByDate_WhenGetData()
        {
            // Arrange
            m_MockArticlesSourceService.Setup(service => service.GetDataAsync(SECTION)).ReturnsAsync(ARTICLE_SOURCES.ToList());
            var articlesService       = new ArticlesService(m_MockArticlesSourceService.Object);
            var expectedArticleGroups = ARTICLE_SOURCES.GroupBy(sourceArticle => sourceArticle.UpdatedDate.Date)
                                        .Select(group => (group.Key.ToString(DATE_FORMAT), group.Count())).ToList();

            // Act
            var articleGroups = await articlesService.GetArticlesGroupsByDateAsync(SECTION, DATE_FORMAT);

            // Assert
            m_MockArticlesSourceService.Verify(service => service.GetDataAsync(SECTION), Times.Once);
            Assert.Equal(expectedArticleGroups, articleGroups);
        }