public async void GetAll_ShouldReturn_JsonList() { // Arrange mockedRep.Setup(x => x.GetAllAsync()).ReturnsAsync(new List <Article>()); // Act var actual = await sut.GetAll(); // Assert Assert.IsType(typeof(JsonResult <IEnumerable <Article> >), actual); }
public async void GetAllArticler()// System.NotSupportedException { var result = await controller.GetAll(); var viewResult = Assert.IsType <ActionResult <List <Article> > >(result); var articleV = Assert.IsType <OkObjectResult>(viewResult.Result); var articleRes = Assert.IsAssignableFrom <IEnumerable <Article> >(articleV.Value); Assert.Equal(2, articleRes.Count()); foreach (var article in articleRes) { var articlePage = await controller.Get(article.Id); var articleView = Assert.IsType <ActionResult <Article> >(articlePage); var articleVw = Assert.IsType <OkObjectResult>(articleView.Result); var articleModel = Assert.IsAssignableFrom <Article>(articleVw.Value); Assert.NotNull(articleModel); Assert.NotNull(articleModel.Text); } }
public async Task UpdateAsync() { IEnumerable <Article> articles = null; _errors.Log($"{nameof(EngagementCountClient)}.{nameof(UpdateAsync)}()", () => { articles = _articles.GetAll(); }); if (articles != null) { foreach (var article in articles) { int engagementCount = await GetEngagementCountAsync(article.Url); SaveEngagementCount(article.Id, engagementCount); } } }