Exemple #1
0
        public void List_Always_CallsRepositoryWithSearchParameters()
        {
            // act
            var parameters = new SearchParameters();

            _articlesController.List(parameters);

            // assert
            _mockArticleRepository.Verify(r => r.Search(It.Is <SearchParameters>(p => p == parameters)));
        }
Exemple #2
0
        public async Task List_TestByUsingMoq_ReturnsArticles()
        {
            //No need to mock other dependencies (IArticleRepository and ILog)
            var articleServices = new Mock <IArticleServices>();

            articleServices.Setup(repo => repo.ListArticlesAsync("Test")).ReturnsAsync(new List <Article>());
            var articleController = new ArticlesController(articleServices.Object);

            var result = await articleController.List();

            Assert.IsAssignableFrom <IEnumerable <Article> >(result);
        }
Exemple #3
0
 private async Task <Paginated <ArticleListItemViewModel> > List(Guid?articleCollectionId, SortBy sortBy = default)
 {
     return((await ArticlesController.List(new ArticleList
     {
         ArticleCollectionId = articleCollectionId,
         Page = new PageFilter
         {
             Index = 1,
         },
         SortBy = sortBy,
     })).ShouldBeOfType <OkObjectResult>()
            .Value.ShouldBeOfType <Paginated <ArticleListItemViewModel> >());
 }