public async Task OnGetAsync_GivenResultsIsNull_ReturnsStatusCodeResult500()
        {
            //Arrange
            ApiResponse <TestScenario> scenario = new ApiResponse <TestScenario>(HttpStatusCode.OK, new TestScenario());

            IScenariosApiClient apiClient = CreateScenariosClient();

            apiClient
            .GetCurrentTestScenarioById(Arg.Is(Scenarioid))
            .Returns(scenario);

            TestScenarioViewModel scenarioViewModel = new TestScenarioViewModel();

            ITestResultsSearchService resultsService = CreateResultsService();

            resultsService
            .PerformProviderTestResultsSearch(Arg.Any <SearchRequestViewModel>())
            .Returns((ProviderTestsSearchResultViewModel)null);

            ViewProviderTestResultsPageModel pageModel = CreatePageModel(scenariosApiClient: apiClient);

            //Act
            IActionResult result = await pageModel.OnGetAsync(Scenarioid, null, "");

            //Assert
            result
            .Should()
            .BeOfType <InternalServerErrorResult>()
            .Which
            .Value
            .Should()
            .Be("Provider Results returned null");
        }
        public async Task OnGetAsync_GivenCountTaskReturnsNoItems_ThenCoverageIsSetCorrectly()
        {
            //Arrange
            ApiResponse <TestScenario> scenario = new ApiResponse <TestScenario>(HttpStatusCode.OK, new TestScenario());

            IScenariosApiClient apiClient = CreateScenariosClient();

            apiClient
            .GetCurrentTestScenarioById(Arg.Is(Scenarioid))
            .Returns(scenario);

            ProviderTestsSearchResultViewModel viewModel = new ProviderTestsSearchResultViewModel();

            ITestResultsSearchService resultsService = CreateResultsService();

            resultsService
            .PerformProviderTestResultsSearch(Arg.Any <SearchRequestViewModel>())
            .Returns(viewModel);

            ITestEngineApiClient testEngineApiClient = CreateTestEngineClient();

            testEngineApiClient
            .GetTestResultCounts(Arg.Any <TestScenarioResultCountsRequestModel>())
            .Returns(new ApiResponse <IEnumerable <TestScenarioResultCounts> >(HttpStatusCode.OK, Enumerable.Empty <TestScenarioResultCounts>()));

            ISpecsApiClient specsApiClient = CreateSpecsClient();

            specsApiClient
            .GetSpecificationSummary(Arg.Any <string>())
            .Returns(new ApiResponse <Clients.SpecsClient.Models.SpecificationSummary>(HttpStatusCode.OK, new Clients.SpecsClient.Models.SpecificationSummary()));

            ViewProviderTestResultsPageModel pageModel = CreatePageModel(
                resultsService, testEngineApiClient,
                scenariosApiClient: apiClient,
                specsApiClient: specsApiClient);

            //Act
            IActionResult result = await pageModel.OnGetAsync(Scenarioid, null, "");

            //Assert
            result
            .Should()
            .BeOfType <PageResult>()
            .Which
            .Should()
            .NotBeNull();

            await testEngineApiClient
            .Received(1)
            .GetTestResultCounts(Arg.Any <TestScenarioResultCountsRequestModel>());

            pageModel
            .TestCoverage
            .Should()
            .Be(0);
        }
        public async Task OnGetAsync_GivenResultsReturned_ReturnsPage()
        {
            //Arrange
            ApiResponse <TestScenario> scenario = new ApiResponse <TestScenario>(HttpStatusCode.OK, new TestScenario());

            IScenariosApiClient scenariosClient = CreateScenariosClient();

            scenariosClient
            .GetCurrentTestScenarioById(Arg.Is(Scenarioid))
            .Returns(scenario);

            TestScenarioViewModel scenarioViewModel = new TestScenarioViewModel();

            ProviderTestsSearchResultViewModel viewModel = new ProviderTestsSearchResultViewModel();

            ITestResultsSearchService resultsService = CreateResultsService();

            resultsService
            .PerformProviderTestResultsSearch(Arg.Any <SearchRequestViewModel>())
            .Returns(viewModel);

            ITestEngineApiClient testEngineClient = CreateTestEngineClient();

            List <TestScenarioResultCounts> countResults = new List <TestScenarioResultCounts>();

            testEngineClient
            .GetTestResultCounts(Arg.Is <TestScenarioResultCountsRequestModel>(c => c.TestScenarioIds.Count() == 1 && c.TestScenarioIds.First() == Scenarioid))
            .Returns(new ApiResponse <IEnumerable <TestScenarioResultCounts> >(HttpStatusCode.OK, countResults));

            ISpecsApiClient specsApiClient = CreateSpecsClient();

            specsApiClient
            .GetSpecificationSummary(Arg.Any <string>())
            .Returns(new ApiResponse <Clients.SpecsClient.Models.SpecificationSummary>(HttpStatusCode.OK, new Clients.SpecsClient.Models.SpecificationSummary()));

            ViewProviderTestResultsPageModel pageModel = CreatePageModel(resultsService, testEngineClient, scenariosClient, specsApiClient: specsApiClient);

            //Act
            IActionResult result = await pageModel.OnGetAsync(Scenarioid, null, "");

            //Assert
            result
            .Should()
            .BeAssignableTo <PageResult>();
        }
        public async Task OnGetAsync_GivenCountTaskReturnsNullContent_ThenErrorIsReturned()
        {
            //Arrange
            ApiResponse <TestScenario> scenario = new ApiResponse <TestScenario>(HttpStatusCode.OK, new TestScenario());

            IScenariosApiClient apiClient = CreateScenariosClient();

            apiClient
            .GetCurrentTestScenarioById(Arg.Is(Scenarioid))
            .Returns(scenario);

            ProviderTestsSearchResultViewModel viewModel = new ProviderTestsSearchResultViewModel();

            ITestResultsSearchService resultsService = CreateResultsService();

            resultsService
            .PerformProviderTestResultsSearch(Arg.Any <SearchRequestViewModel>())
            .Returns(viewModel);

            ITestEngineApiClient testEngineApiClient = CreateTestEngineClient();

            testEngineApiClient
            .GetTestResultCounts(Arg.Any <TestScenarioResultCountsRequestModel>())
            .Returns(new ApiResponse <IEnumerable <TestScenarioResultCounts> >(HttpStatusCode.OK, null));

            ViewProviderTestResultsPageModel pageModel = CreatePageModel(resultsService, testEngineApiClient, scenariosApiClient: apiClient);

            //Act
            IActionResult result = await pageModel.OnGetAsync(Scenarioid, null, "");

            //Assert
            result
            .Should()
            .BeOfType <InternalServerErrorResult>()
            .Which
            .Value
            .Should()
            .Be("Count Task result content was null");

            await testEngineApiClient
            .Received(1)
            .GetTestResultCounts(Arg.Any <TestScenarioResultCountsRequestModel>());
        }
        public async Task OnGetAsync_GivenScenarioNotReturned_ReturnsNotFoundResult()
        {
            //Arrange
            ApiResponse <TestScenario> scenario = new ApiResponse <TestScenario>(HttpStatusCode.NotFound);

            IScenariosApiClient apiClient = CreateScenariosClient();

            apiClient
            .GetCurrentTestScenarioById(Arg.Is(Scenarioid))
            .Returns(scenario);

            ViewProviderTestResultsPageModel pageModel = CreatePageModel(scenariosApiClient: apiClient);

            //Act
            IActionResult result = await pageModel.OnGetAsync(Scenarioid, null, "");

            //Assert
            result
            .Should()
            .BeAssignableTo <NotFoundResult>();
        }