示例#1
0
        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);
        }
示例#2
0
        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>();
        }
示例#3
0
        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>();
        }