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))); }
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); }
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> >()); }