public void GetHomeViewModelShouldGetVacancies() { var searchViewModel = new DashboardVacancySummariesSearchViewModel(); var vacancies = new List <DashboardVacancySummaryViewModel> { new DashboardVacancySummaryViewModel { Title = "Vacancy 1" } }; var vacancyProvider = new Mock <IVacancyQAProvider>(); vacancyProvider.Setup(vp => vp.GetPendingQAVacanciesOverview(searchViewModel)).Returns(new DashboardVacancySummariesViewModel { Vacancies = vacancies }); var configurationService = new Mock <IConfigurationService>(); configurationService.Setup(c => c.Get <ManageWebConfiguration>()) .Returns(new ManageWebConfiguration { AuthorisationGroupClaim = ValidAuthorisationGroupClaim }); var mediator = new AgencyUserMediatorBuilder().With(vacancyProvider).With(configurationService).Build(); var principal = new ClaimsPrincipalBuilder().WithName("User001").WithGroup(ValidAuthorisationGroupClaim).Build(); var response = mediator.GetHomeViewModel(principal, searchViewModel); response.AssertCodeAndMessage(AgencyUserMediatorCodes.GetHomeViewModel.OK); vacancyProvider.Verify(vp => vp.GetPendingQAVacanciesOverview(searchViewModel), Times.Once); response.ViewModel.VacancySummaries.Vacancies.ShouldBeEquivalentTo(vacancies); }
public ActionResult Dashboard(DashboardVacancySummariesSearchViewModel searchViewModel) { var claimsPrincipal = (ClaimsPrincipal)User; var response = _agencyUserMediator.GetHomeViewModel(claimsPrincipal, searchViewModel); return(View(response.ViewModel)); }
public void NoVacanciesForSelectionAllowReview() { var searchViewModel = new DashboardVacancySummariesSearchViewModel { FilterType = VacanciesSummaryFilterTypes.SubmittedMoreThan48Hours, Mode = DashboardVacancySummariesMode.Review }; int total; _vacancyPostingService.Reset(); _vacancyPostingService.Setup(p => p.GetWithStatus(It.IsAny <VacancySummaryByStatusQuery>(), out total)).Returns(_vacanciesSubmittedToday); var metrics = new List <RegionalTeamMetrics>() { new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.EastAnglia, TotalCount = 1 }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.EastMidlands }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.North }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.NorthWest }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.SouthEast }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.SouthWest }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.WestMidlands }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.YorkshireAndHumberside }, }; _vacancyPostingService.Setup(p => p.GetRegionalTeamsMetrics(It.IsAny <VacancySummaryByStatusQuery>())).Returns(metrics); //Act var vacancySummariesViewModel = _provider.GetPendingQAVacanciesOverview(searchViewModel); //Assert vacancySummariesViewModel.SearchViewModel.Mode.Should().Be(DashboardVacancySummariesMode.Review); }
public void NoVacanciesRedirectToMetrics() { //Arrange var searchViewModel = new DashboardVacancySummariesSearchViewModel { Mode = DashboardVacancySummariesMode.Review }; int total; _vacancyPostingService.Reset(); _vacancyPostingService.Setup(p => p.GetWithStatus(It.IsAny <VacancySummaryByStatusQuery>(), out total)).Returns(new List <VacancySummary>()); var metrics = new List <RegionalTeamMetrics>() { new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.EastAnglia }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.EastMidlands }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.North }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.NorthWest }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.SouthEast }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.SouthWest }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.WestMidlands }, new RegionalTeamMetrics() { RegionalTeam = RegionalTeam.YorkshireAndHumberside }, }; _vacancyPostingService.Setup(p => p.GetRegionalTeamsMetrics(It.IsAny <VacancySummaryByStatusQuery>())).Returns(metrics); //Act var vacancySummariesViewModel = _provider.GetPendingQAVacanciesOverview(searchViewModel); //Assert vacancySummariesViewModel.SearchViewModel.Mode.Should().Be(DashboardVacancySummariesMode.Metrics); }
public MediatorResponse <HomeViewModel> GetHomeViewModel(ClaimsPrincipal principal, DashboardVacancySummariesSearchViewModel searchViewModel) { var username = principal.Identity.Name; var userViewModel = _agencyUserProvider.GetAgencyUser(username); var vacancySummariesViewModel = _vacancyQaProvider.GetPendingQAVacanciesOverview(searchViewModel); var homeViewModel = new HomeViewModel { AgencyUser = userViewModel, VacancySummaries = vacancySummariesViewModel }; return(GetMediatorResponse(AgencyUserMediatorCodes.GetHomeViewModel.OK, homeViewModel)); }
public void BasicCountTests() { //Arrange var searchViewModel = new DashboardVacancySummariesSearchViewModel { FilterType = VacanciesSummaryFilterTypes.All }; //Act var vacancySummariesViewModel = _provider.GetPendingQAVacanciesOverview(searchViewModel); //Assert vacancySummariesViewModel.Vacancies.Should().NotBeNullOrEmpty(); vacancySummariesViewModel.Vacancies.Count.Should().Be(18); }
public void ReturnsCorrectSearchViewModel() { //Arrange var searchViewModel = new DashboardVacancySummariesSearchViewModel { FilterType = VacanciesSummaryFilterTypes.All }; //Act var vacancySummariesViewModel = _provider.GetPendingQAVacanciesOverview(searchViewModel); //Assert vacancySummariesViewModel.SearchViewModel.FilterType.Should().Be(VacanciesSummaryFilterTypes.All); vacancySummariesViewModel.SearchViewModel.Should().Be(searchViewModel); }