Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }