public async Task GetCategoryRelatedNews_ShouldReturnNotFound() { var status = HttpStatusCode.NotFound; var mockService = new Mock <IFavoriteService>(); var mockHttp = GetHttpClient(status); var controller = new NewsController(mockService.Object, mockHttp); var result = await controller.GetCategoryRelatedNews("general", 1, 3); var actionResult = Assert.IsType <NotFoundObjectResult>(result); Assert.Equal(404, actionResult.StatusCode); }
public async Task GetCategoryRelatedNews_ShouldReturnArticles() { var status = HttpStatusCode.OK; var mockService = new Mock <IFavoriteService>(); var mockHttp = GetHttpClient(status); var controller = new NewsController(mockService.Object, mockHttp); var result = await controller.GetCategoryRelatedNews("general", 1, 3); var actionResult = Assert.IsType <OkObjectResult>(result); var model = actionResult.Value as NewsApiModel; Assert.Equal(3, model.TotalResults); Assert.Equal(3, model.Articles.Count); }