예제 #1
0
        public async Task GetResultsByCategory(bool hasMatchedProfile, int expectedNumberOfcalls)
        {
            //Arrange
            var category        = "ACategory";
            var resultsResponse = new GetResultsResponse()
            {
                SessionId = sessionId
            };

            if (hasMatchedProfile)
            {
                List <JobProfileResult> profiles = new List <JobProfileResult>
                {
                    new JobProfileResult()
                    {
                        UrlName = "Cname1", JobCategory = category
                    }
                };
                resultsResponse.JobProfiles = profiles;

                List <JobCategoryResult> categories = new List <JobCategoryResult>
                {
                    new JobCategoryResult()
                    {
                        JobFamilyName = category, JobFamilyUrl = category
                    }
                };
                resultsResponse.JobCategories = categories;
            }

            A.CallTo(() => resultsApiService.GetResults(sessionId, A <string> .Ignored)).Returns(resultsResponse);
            A.CallTo(() => jPOverviewAPIService.GetOverviewsForProfilesAsync(A <IEnumerable <string> > .Ignored)).Returns(A.CollectionOfDummy <JobProfileOverView>(2));

            //Act
            var results = await resultsService.GetResultsByCategory(category);

            //Assert
            A.CallTo(() => resultsApiService.GetResults(sessionId, category)).MustHaveHappenedOnceExactly();
            A.CallTo(() => jPOverviewAPIService.GetOverviewsForProfilesAsync(A <IEnumerable <string> > .Ignored)).MustHaveHappened(expectedNumberOfcalls, Times.Exactly);
            results.SessionId.Should().Be(sessionId);
        }
예제 #2
0
        public async Task <IActionResult> Roles(string id)
        {
            if (!await HasSessionId().ConfigureAwait(false))
            {
                return(RedirectToRoot());
            }

            var assessmentResponse = await apiService.GetAssessment().ConfigureAwait(false);

            if (!assessmentResponse.IsComplete && !assessmentResponse.IsFilterAssessment)
            {
                return(RedirectTo("assessment/return"));
            }

            var resultsResponse = await resultsService.GetResultsByCategory(id).ConfigureAwait(false);

            var resultsByCategoryModel = mapper.Map <ResultsByCategoryModel>(resultsResponse);

            resultsByCategoryModel.AssessmentReference = assessmentResponse.ReferenceCode;

            this.logService.LogInformation($"{nameof(this.Roles)} generated the model and ready to pass to the view");

            return(View("ResultsByCategory", resultsByCategoryModel));
        }