public async Task Get_returns_200_and_company() { var keywords = new [] { "Testing", "C#", "Java", "FullStack", "Frontend", "Backend", "UML", "DevOps", "Communication", "JavaScript" }; repository.Setup(r => r.GetKeywordsAsync()).ReturnsAsync(keywords); var controller = new KeywordRepositoryController(repository.Object); var actual = await controller.Get(true); var actionResult = Assert.IsType <ActionResult <IEnumerable <string> > >(actual); var okResult = Assert.IsType <OkObjectResult>(actionResult.Result); var actualCompanies = Assert.IsType <List <string> >(okResult.Value); Assert.Equal(200, okResult.StatusCode); Assert.Equal(keywords, actualCompanies); }
public async Task Get_returns_500_on_internal_error() { repository.Setup(r => r.GetKeywordsAsync()).ThrowsAsync(new Exception()); var controller = new KeywordRepositoryController(repository.Object); var actual = await controller.Get(true); var actionResult = Assert.IsType <ActionResult <IEnumerable <string> > >(actual); var code = Assert.IsType <StatusCodeResult>(actionResult.Result); Assert.Equal(500, code.StatusCode); }