public void RemoveTest() { SetupMembers(); GroupingCollection group = new GroupingCollection(null); group.InsertAtEnd(this.pg1); group.InsertAtEnd(this.ig1); group.InsertAtBeginning(this.pg2); group.InsertAtEnd(this.ig2); group.InsertAfter(this.ig3, this.ig2); group.InsertAfter(this.pg3, this.pg2); AssertNPropertyGroupsInCollection(group, 3); AssertNItemGroupsInCollection(group, 3); group.RemovePropertyGroup(this.pg3); AssertNPropertyGroupsInCollection(group, 2); AssertNItemGroupsInCollection(group, 3); group.RemovePropertyGroup(this.pg2); AssertNPropertyGroupsInCollection(group, 1); AssertNItemGroupsInCollection(group, 3); group.RemoveItemGroup(this.ig2); AssertNPropertyGroupsInCollection(group, 1); AssertNItemGroupsInCollection(group, 2); }
public void EnumerationTest() { SetupMembers(); GroupingCollection group = new GroupingCollection(null); group.InsertAtEnd(this.pg1); group.InsertAtEnd(this.ig1); group.InsertAtEnd(this.pg2); group.InsertAtEnd(this.ig2); group.InsertAtEnd(this.ig3); AssertNPropertyGroupsInCollection(group, 2); Assertion.Assert(group.PropertyGroupCount == 2); AssertNItemGroupsInCollection(group, 3); Assertion.Assert(group.ItemGroupCount == 3); group.InsertAtEnd(this.choose1); group.InsertAtEnd(this.choose2); AssertNPropertyGroupsInCollection(group, 2); Assertion.Assert(group.PropertyGroupCount == 2); AssertNItemGroupsInCollection(group, 3); Assertion.Assert(group.ItemGroupCount == 3); AssertNPropertyGroupsAndChoosesInCollection(group, 4); AssertNItemGroupsAndChoosesInCollection(group, 5); }
public ActionResult Index() { var serviceController = new Service.Library.Controllers.Settings(); var results = serviceController.Search(o => o.Viewable); if (results.Failed || results.Entity == null || !results.Entity.Any()) { throw new ApplicationException(results.Message); } var model = new SettingsViewModel(); model.SidebarMenu = BuildSidebarMenu("Admin", "Settings"); var settings = results.Entity; var groupings = settings.Select(x => x.ExternalSystem).Distinct().ToList(); var groupCollection = new GroupingCollection { Groupings = new List <Grouping>(), R1SMGroup = null }; if (settings.Any(x => x.ExternalSystem.Name == Constants.R1SMSystemName && x.Viewable)) { var r1SMGroup = new Grouping { Name = Constants.R1SMSystemName, Label = "The settings below control how the Resource One Security Manager operates.", SettingCollection = settings.Where(x => x.ExternalSystem.Name == Constants.R1SMSystemName).Select( x => new SettingModel(x)).ToList() }; groupCollection.R1SMGroup = r1SMGroup; } foreach (var grouping in groupings.Where(x => x.Name != Constants.R1SMSystemName).OrderBy(x => x.Name)) { if (!settings.Any(x => x.SystemId == grouping.Id && x.Viewable)) { continue; } var group = new Grouping { Name = grouping.Name, Label = string.Format( "The settings below control how the Resource One Security Manager interfaces with {0} for {1} data.", grouping.Name, grouping.DirectionLabel.ToLower()), SettingCollection = settings.Where(x => x.SystemId == grouping.Id).Select(x => new SettingModel(x)).ToList() }; groupCollection.Groupings.Add(group); } model.GroupingCollection = groupCollection; return(View(model)); }
public void LinkedCount() { SetupMembers(); GroupingCollection masterGroup = new GroupingCollection(null); GroupingCollection childGroup1 = new GroupingCollection(masterGroup); GroupingCollection childGroup2 = new GroupingCollection(masterGroup); GroupingCollection nestedGroup = new GroupingCollection(childGroup1); nestedGroup.InsertAtEnd(this.ig1); nestedGroup.InsertAfter(this.ig2, this.ig1); nestedGroup.InsertAtBeginning(this.pg1); childGroup1.InsertAtEnd(this.ig1); childGroup1.InsertAtBeginning(this.pg1); childGroup2.InsertAtBeginning(this.pg1); masterGroup.InsertAtEnd(this.ig1); masterGroup.InsertAfter(this.ig2, this.ig1); masterGroup.InsertAtEnd(this.pg2); Assertion.AssertEquals(nestedGroup.ItemGroupCount, 2); Assertion.AssertEquals(nestedGroup.PropertyGroupCount, 1); Assertion.AssertEquals(childGroup1.ItemGroupCount, 1 + 2); Assertion.AssertEquals(childGroup1.PropertyGroupCount, 1 + 1); Assertion.AssertEquals(childGroup2.ItemGroupCount, 0); Assertion.AssertEquals(childGroup2.PropertyGroupCount, 1); Assertion.AssertEquals(masterGroup.ItemGroupCount, 2 + 0 + 1 + 2); Assertion.AssertEquals(masterGroup.PropertyGroupCount, 1 + 1 + 1 + 1); nestedGroup.Clear(); nestedGroup.InsertAtEnd(this.ig2); nestedGroup.InsertAfter(this.ig3, this.ig2); childGroup1.RemovePropertyGroup(this.pg1); childGroup1.RemoveItemGroup(this.ig1); childGroup1.InsertAtEnd(this.ig3); childGroup2.RemovePropertyGroup(this.pg1); masterGroup.RemoveItemGroup(this.ig2); Assertion.AssertEquals(nestedGroup.ItemGroupCount, 2); Assertion.AssertEquals(nestedGroup.PropertyGroupCount, 0); Assertion.AssertEquals(childGroup1.ItemGroupCount, 1 + 2); Assertion.AssertEquals(childGroup1.PropertyGroupCount, 0 + 0); Assertion.AssertEquals(childGroup2.ItemGroupCount, 0); Assertion.AssertEquals(childGroup2.PropertyGroupCount, 0); Assertion.AssertEquals(masterGroup.ItemGroupCount, 1 + 0 + 1 + 2); Assertion.AssertEquals(masterGroup.PropertyGroupCount, 1 + 0 + 0 + 0); }
private void AssertNPropertyGroupsAndChoosesInCollection(GroupingCollection group, int n) { int count; count = 0; foreach (IItemPropertyGrouping pg in new GroupEnumeratorHelper(group, GroupEnumeratorHelper.ListType.PropertyGroupsTopLevelAndChoose)) { count++; } Assertion.AssertEquals(n, count); }
private void AssertNItemGroupsInCollection(GroupingCollection group, int n) { int count; count = 0; foreach (IItemPropertyGrouping pg in new GroupEnumeratorHelper(group, GroupEnumeratorHelper.ListType.ItemGroupsAll)) { count++; } Assertion.AssertEquals(n, count); // ItemGroupCount uses a different mechanism to obtain the total count, so verify it as well Assertion.AssertEquals(n, group.ItemGroupCount); }
public void InsertionTest() { SetupMembers(); GroupingCollection group = new GroupingCollection(null); group.InsertAtEnd(this.pg1); group.InsertAtEnd(this.ig1); group.InsertAtBeginning(this.pg2); group.InsertAtEnd(this.ig2); group.InsertAfter(this.ig3, this.ig2); group.InsertAfter(this.pg3, this.pg2); AssertNPropertyGroupsInCollection(group, 3); Assertion.Assert(group.PropertyGroupCount == 3); AssertNItemGroupsInCollection(group, 3); Assertion.Assert(group.ItemGroupCount == 3); group.InsertAtEnd(this.choose1); group.InsertAtEnd(this.choose2); }