// GET: AdminPanel public ActionResult Index() { var model = new SkillsFrameworkImportViewModel { PageTitle = PageTitle, FirstParagraph = FirstParagraph, NotAllowedMessage = NotAllowedMessage, IsAdmin = webAppContext.IsUserAdministrator, SocMappingStatus = importSkillsFrameworkDataService.GetSocMappingStatus(), NextBatchOfSOCsToImport = importSkillsFrameworkDataService.GetNextBatchOfSOCsToImport(BatchSizeForImport) }; return(View(model)); }
public void IndexModeTest(bool isAdmin, string mode, int batchSizeForImport) { // Assign A.CallTo(() => fakeReportAuditRepository.GetAllAuditRecords()).Returns(GetAuditRecords()); A.CallTo(() => fakeImportSkillsFrameworkDataService.ImportFrameworkSkills()).Returns(new FrameworkSkillsImportResponse()); var skillsFrameworkDataImportController = GetSkillsFrameworkDataImportController(isAdmin, batchSizeForImport); // Act var indexMethodCall = skillsFrameworkDataImportController.WithCallTo(c => c.Index(mode)); // Assert if (isAdmin) { indexMethodCall .ShouldRenderView("ImportResults") .WithModel <SkillsFrameworkResultsViewModel>(vm => { vm.FirstParagraph.Should().BeEquivalentTo(skillsFrameworkDataImportController.FirstParagraph); vm.IsAdmin.Should().Be(fakeWebAppContext.IsUserAdministrator); vm.NotAllowedMessage.Should().BeEquivalentTo(skillsFrameworkDataImportController.NotAllowedMessage); vm.PageTitle.Should().BeEquivalentTo(skillsFrameworkDataImportController.PageTitle); vm.AuditRecords.Should().BeEquivalentTo(fakeReportAuditRepository.GetAllAuditRecords()); }) .AndNoModelErrors(); switch (mode?.ToUpperInvariant().Trim()) { case "IMPORTSKILLS": A.CallTo(() => fakeImportSkillsFrameworkDataService.ImportFrameworkSkills()).MustHaveHappened(); break; case "UPDATESOCOCCUPATIONALCODES": A.CallTo(() => fakeImportSkillsFrameworkDataService.UpdateSocCodesOccupationalCode()).MustHaveHappened(); break; case "RESETSOCIMPORTALLSTATUS": A.CallTo(() => fakeImportSkillsFrameworkDataService.ResetAllSocStatus()).MustHaveHappened(); break; case "RESETSOCIMPORTSTARTEDSTATUS": A.CallTo(() => fakeImportSkillsFrameworkDataService.ResetStartedSocStatus()).MustHaveHappened(); break; case "EXPORTNEWONETMAPPINGS": A.CallTo(() => fakeImportSkillsFrameworkDataService.ExportNewONetMappings()).MustHaveHappened(); break; default: A.CallTo(() => fakeImportSkillsFrameworkDataService.UpdateSocCodesOccupationalCode()).MustNotHaveHappened(); A.CallTo(() => fakeImportSkillsFrameworkDataService.ImportFrameworkSkills()).MustNotHaveHappened(); break; } A.CallTo(() => fakeWebAppContext.IsUserAdministrator).MustHaveHappened(); A.CallTo(() => fakeReportAuditRepository.GetAllAuditRecords()).MustHaveHappened(); A.CallTo(() => fakeImportSkillsFrameworkDataService.GetSocMappingStatus()).MustHaveHappened(); A.CallTo(() => fakeImportSkillsFrameworkDataService.GetNextBatchOfSOCsToImport(10)).MustHaveHappened(); } else { indexMethodCall .ShouldRenderView("ImportResults") .WithModel <SkillsFrameworkResultsViewModel>(vm => { vm.FirstParagraph.Should().BeEquivalentTo(skillsFrameworkDataImportController.FirstParagraph); vm.IsAdmin.Should().Be(fakeWebAppContext.IsUserAdministrator); vm.NotAllowedMessage.Should().BeEquivalentTo(skillsFrameworkDataImportController.NotAllowedMessage); vm.PageTitle.Should().BeEquivalentTo(skillsFrameworkDataImportController.PageTitle); vm.OtherMessage.Should().BeEquivalentTo(skillsFrameworkDataImportController.NotAllowedMessage); vm.AuditRecords.Should().BeEquivalentTo(fakeReportAuditRepository.GetAllAuditRecords()); }).AndNoModelErrors(); } }