public async Task SearchTestScenarios_GivenNullResultsReturnedFromSearch_ReturnsStatusCode500() { // Arrange SearchRequestViewModel requestModel = new SearchRequestViewModel(); ITestScenarioSearchService searchService = CreateTestScenarioSearchService(); searchService .PerformSearch(Arg.Any <SearchRequestViewModel>()) .Returns((TestScenarioSearchResultViewModel)null); TestScenarioSearchController controller = CreateController(searchService); // Act IActionResult actionResult = await controller.SearchTestScenarios(requestModel); // Asserts actionResult .Should() .BeOfType <StatusCodeResult>(); StatusCodeResult statusCodeResult = actionResult as StatusCodeResult; statusCodeResult .StatusCode .Should() .Be(500); }
public void SearchTestScenarios_GivenNullRequestObject_ThrowsArgumentNullException() { // Arrange TestScenarioSearchController controller = CreateController(); SearchRequestViewModel requestModel = null; // Act Func <Task> test = async() => await controller.SearchTestScenarios(requestModel); // Assert test .Should() .ThrowExactly <ArgumentNullException>(); }
public async Task SearchTestScenarios_GivenResultsReturnedFromSearch_ReturnsOK() { // Arrange SearchRequestViewModel requestModel = new SearchRequestViewModel(); TestScenarioSearchResultViewModel results = new TestScenarioSearchResultViewModel(); ITestScenarioSearchService searchService = CreateTestScenarioSearchService(); searchService .PerformSearch(Arg.Any <SearchRequestViewModel>()) .Returns(results); TestScenarioSearchController controller = CreateController(searchService); // Act IActionResult actionResult = await controller.SearchTestScenarios(requestModel); // Asserts actionResult .Should() .BeOfType <OkObjectResult>(); }