public void TopLevelMenuItemWithNoChildrenShouldNotRenderTest() { var menuItem1 = new LtInfoMenuItem("menu1"); var result = menuItem1.RenderMenu().ToString(); Assert.That(result, Is.EqualTo(string.Empty), "Is top level menu and has no children and has no url, should return empty"); }
public void CanRenderSimpleMenuTest() { var menuItem1 = new LtInfoMenuItem("url1", "menu1", true, false, null); var result = menuItem1.RenderMenu(); Approvals.Verify(result); }
public void CanRenderBlankMenuTest() { var menuItem1 = new LtInfoMenuItem("menu1"); var result = menuItem1.RenderMenu().ToString(); Assert.That(result, Is.EqualTo(string.Empty), "No visible menu items, should return empty"); }
private static LtInfoMenuItem BuildDelineationMenu(Person currentPerson) { var delineationMenu = new LtInfoMenuItem("Delineation"); delineationMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <DelineationController>(c => c.DelineationMap(null)), currentPerson, "Delineation Map", "Group1")); delineationMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <DelineationController>(c => c.DelineationReconciliationReport()), currentPerson, "Delineation Reconciliation Report", "Group1")); return(delineationMenu); }
private static LtInfoMenuItem BuildProgramInfoMenu(Person currentPerson) { var programInfoMenu = new LtInfoMenuItem("Program Info"); programInfoMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPAssessmentObservationTypeController>(c => c.Index()), currentPerson, "Observation Types", "Group1")); programInfoMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPTypeController>(c => c.Index()), currentPerson, "Treatment BMP Types", "Group1")); programInfoMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <FundingSourceController>(c => c.Index()), currentPerson, FieldDefinitionType.FundingSource.GetFieldDefinitionLabelPluralized(), "Group1")); if (new JurisdictionEditFeature().HasPermissionByPerson(currentPerson)) { programInfoMenu.AddMenuItem(LtInfoMenuItem.MakeItem( new SitkaRoute <WebServicesController>(c => c.Index()), currentPerson, "Web Services", "Group 2")); } return(programInfoMenu); }
private static LtInfoMenuItem BuildBMPInventoryMenu(Person currentPerson) { var bmpMenu = new LtInfoMenuItem("BMP Inventory"); //bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute<JurisdictionController>(c => c.Index()), currentPerson, "Jurisdictions", "Group1")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPController>(c => c.FindABMP()), currentPerson, "Find a BMP", "Group1")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPController>(c => c.ViewTreatmentBMPModelingAttributes()), currentPerson, "Modeling Parameters", "Group1")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPController>(c => c.Index()), currentPerson, "View All BMPs", "Group1")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPController>(c => c.TreatmentBMPAssessmentSummary()), currentPerson, "View Latest BMP Assessments", "Group2")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <FieldVisitController>(c => c.Index()), currentPerson, "View All Field Records", "Group2")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <WaterQualityManagementPlanController>(c => c.Index()), currentPerson, FieldDefinitionType.WaterQualityManagementPlan.GetFieldDefinitionLabelPluralized(), "Group3")); bmpMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <ParcelController>(c => c.Index()), currentPerson, "Parcels", "Group3")); return(bmpMenu); }
public void CanRenderMenuWithGroupsTest() { var menuItem1 = new LtInfoMenuItem("menu1"); var menuItem2 = new LtInfoMenuItem("url2", "menu2", true, false, "1"); menuItem1.AddMenuItem(menuItem2); var menuItem3 = new LtInfoMenuItem("url3", "menu3", true, false, "1"); menuItem1.AddMenuItem(menuItem3); var menuItem4 = new LtInfoMenuItem("url4", "menu4", true, false, "2"); menuItem1.AddMenuItem(menuItem4); var menuItem5 = new LtInfoMenuItem(null, "menu5", true, false, "2"); menuItem1.AddMenuItem(menuItem5); var menuItem6 = new LtInfoMenuItem("url6", "menu6", true, false, null); menuItem5.AddMenuItem(menuItem6); var menuItem7 = new LtInfoMenuItem("menu7"); var menuItem8 = new LtInfoMenuItem("url8", "menu8", true, false, "3"); menuItem7.AddMenuItem(menuItem8); var menuItem9 = new LtInfoMenuItem("url9", "menu9", true, false, null); menuItem7.AddMenuItem(menuItem9); var menuItem10 = new LtInfoMenuItem("menu10"); var menuItem11 = new LtInfoMenuItem("url11", "menu11", true, false, null); menuItem10.AddMenuItem(menuItem11); var menuItem12 = new LtInfoMenuItem("url12", "menu12", true, true, null); var menuItem13 = new LtInfoMenuItem("menu13"); var topLevelMenus = new List <LtInfoMenuItem> { menuItem1, menuItem7, menuItem10, menuItem12, menuItem13 }; var result = string.Join("\r\n", topLevelMenus.Select(x => x.RenderMenu())); Approvals.Verify(result); }
public void CanRenderNestedMenuTest() { var menuItem1 = new LtInfoMenuItem("menu1"); var menuItem2 = new LtInfoMenuItem("url2", "menu2", true, false, null); menuItem1.AddMenuItem(menuItem2); var menuItem3 = new LtInfoMenuItem("url3", "menu3", true, false, null); menuItem1.AddMenuItem(menuItem3); var menuItem4 = new LtInfoMenuItem("url4", "menu4", true, false, null); menuItem1.AddMenuItem(menuItem4); var menuItem5 = new LtInfoMenuItem(null, "menu5", true, false, null); menuItem1.AddMenuItem(menuItem5); var menuItem6 = new LtInfoMenuItem("url6", "menu6", true, false, null); menuItem5.AddMenuItem(menuItem6); var result = menuItem1.RenderMenu(); Approvals.Verify(result); }
private LtInfoMenuItem BuildManageMenu(Person currentPerson) { var manageMenu = new LtInfoMenuItem("Manage"); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <HomeController>(c => c.ManageHomePageImages()), currentPerson, "Homepage Configuration", "Group1")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <NeptunePageController>(c => c.Index()), currentPerson, "Page Content", "Group1")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <FieldDefinitionController>(c => c.Index()), currentPerson, "Custom Labels & Definitions", "Group1")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <UserController>(c => c.Index()), currentPerson, "Users", "Group1")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <OrganizationController>(c => c.Index()), currentPerson, $"{FieldDefinitionType.Organization.GetFieldDefinitionLabelPluralized()}", "Group1")); if (currentPerson.IsAdministrator()) { manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <JurisdictionController>(c => c.Index()), currentPerson, "Jurisdictions", "Group1")); } manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TreatmentBMPAssessmentObservationTypeController>(c => c.Manage()), currentPerson, "Observation Types", "Group2")); if (!currentPerson.IsAnonymousOrUnassigned()) { manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem( new SitkaRoute <TreatmentBMPTypeController>(c => c.Manage()), currentPerson, "Treatment BMP Types", "Group2")); } manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <CustomAttributeTypeController>(c => c.Manage()), currentPerson, "Custom Attributes", "Group2")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <TrashGeneratingUnitController>(c => c.Index()), currentPerson, "Trash Generating Units", "Group3")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <LandUseBlockController>(c => c.Index()), currentPerson, "Land Use Blocks", "Group3")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <HRUCharacteristicController>(c => c.Index()), currentPerson, "HRU Characteristics", "Group4")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <RegionalSubbasinController>(c => c.Index()), currentPerson, "Regional Subbasins", "Group4")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <RegionalSubbasinController>(c => c.Grid()), currentPerson, "Regional Subbasin Grid", "Group4")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <RegionalSubbasinRevisionRequestController>(c => c.Index()), currentPerson, "Regional Subbasin Revision Requests", "Group4")); manageMenu.AddMenuItem(LtInfoMenuItem.MakeItem(new SitkaRoute <WaterQualityManagementPlanController>(c => c.LGUAudit()), currentPerson, "Water Quality Management Plan LGU Audit", "Group5")); return(manageMenu); }
public void TopLevelMenuItemThatIsNotALinkCanAddChildrenTest() { var menuItem1 = new LtInfoMenuItem("menu1"); Assert.DoesNotThrow(() => menuItem1.AddMenuItem(new LtInfoMenuItem("Some menu item"))); }
public void TopLevelMenuItemThatIsALinkCannotAddChildrenTest() { var menuItem1 = new LtInfoMenuItem("url1", "menu1", true, true, null); Assert.Throws <PreconditionException>(() => menuItem1.AddMenuItem(new LtInfoMenuItem("Some menu item"))); }
public void AddMenuItem(LtInfoMenuItem menuItemToAdd) { Check.Require(!HasUrl, "You cannot add children to a menu item that is a link!"); ChildMenus.Add(menuItemToAdd); }