public void GetSortedArticlesTest_ReturnsListOfArticles() { var articles = ArticleHelper.GetRandomTestArticles(10); var expectedArticles = articles.Take(3).ToList(); string title = expectedArticles.ElementAt(0).Title; string userName = expectedArticles.ElementAt(1).UserName; string category = expectedArticles.ElementAt(2).Category.ToString(); _mockArticleService.Setup(ser => ser.GetArticlesByOccurrenceAsync(title, userName, category) ).ReturnsAsync(expectedArticles); var okObjectResult = (_controller.GetSortedArticles(title, userName, category).Result.Result as OkObjectResult)?.Value; var result = okObjectResult as IEnumerable <Article> ?? throw new InvalidOperationException(); Assert.Contains(result, article => articles.Any(a => a.Category == article.Category && a.UserName == article.UserName && a.Content == article.Content && a.CreatedDate == article.CreatedDate && a.Id == article.Id && a.Title == article.Title)); }