Ejemplo n.º 1
0
        [Test] // Sort (IComparer)
        public void Sort3()
        {
            EventDescriptorCollection descriptors;
            EventDescriptorCollection sorted;

            EventDescriptor descA = new MockEventDescriptor("Foo", "B");
            EventDescriptor descB = new MockEventDescriptor("Aim", "C");
            EventDescriptor descC = new MockEventDescriptor("Bim", "A");
            EventDescriptor descD = new MockEventDescriptor("AIm", "E");
            EventDescriptor descE = new MockEventDescriptor("Boo", "D");
            EventDescriptor descF = new MockEventDescriptor("FOo", "F");

            EventDescriptor [] props = new EventDescriptor []
            {
                descA, descB, descC, descD, descE, descF
            };
            descriptors = new EventDescriptorCollection(props);

            Assert.AreSame(descA, descriptors [0], "#A1");
            Assert.AreSame(descB, descriptors [1], "#A2");
            Assert.AreSame(descC, descriptors [2], "#A3");
            Assert.AreSame(descD, descriptors [3], "#A4");
            Assert.AreSame(descE, descriptors [4], "#A5");
            Assert.AreSame(descF, descriptors [5], "#A6");

            sorted = descriptors.Sort(new CategoryComparer());

            Assert.AreSame(descA, descriptors [0], "#B1");
            Assert.AreSame(descB, descriptors [1], "#B2");
            Assert.AreSame(descC, descriptors [2], "#B3");
            Assert.AreSame(descD, descriptors [3], "#B4");
            Assert.AreSame(descE, descriptors [4], "#B5");
            Assert.AreSame(descF, descriptors [5], "#B6");

            Assert.AreSame(descC, sorted [0], "#C1");
            Assert.AreSame(descA, sorted [1], "#C2");
            Assert.AreSame(descB, sorted [2], "#C3");
            Assert.AreSame(descE, sorted [3], "#C4");
            Assert.AreSame(descD, sorted [4], "#C5");
            Assert.AreSame(descF, sorted [5], "#C6");

            sorted = descriptors.Sort((Comparer)null);

            Assert.AreSame(descA, descriptors [0], "#D1");
            Assert.AreSame(descB, descriptors [1], "#D2");
            Assert.AreSame(descC, descriptors [2], "#D3");
            Assert.AreSame(descD, descriptors [3], "#D4");
            Assert.AreSame(descE, descriptors [4], "#D5");
            Assert.AreSame(descF, descriptors [5], "#D6");

            Assert.AreSame(descB, sorted [0], "#E1");
            Assert.AreSame(descD, sorted [1], "#E2");
            Assert.AreSame(descC, sorted [2], "#E3");
            Assert.AreSame(descE, sorted [3], "#E4");
            Assert.AreSame(descA, sorted [4], "#E5");
            Assert.AreSame(descF, sorted [5], "#E6");
        }
Ejemplo n.º 2
0
        public EventFilterList()
        {
            EventDescriptorCollection edColl = TypeDescriptor.GetEvents(typeof(Control));

            edColl = edColl.Sort();
            Add(new EventFilterLine("Custom Events", true));
            for (int i = 0; i < edColl.Count; i++)
            {
                Add(new EventFilterLine(edColl[i].Name, true));
            }
        }
        public void Sort4()
        {
            EventDescriptorCollection descriptors;
            EventDescriptorCollection sorted;

            EventDescriptor descA = new MockEventDescriptor("Foo", "B");
            EventDescriptor descB = new MockEventDescriptor("Aim", "C");
            EventDescriptor descC = new MockEventDescriptor("Bim", "A");
            EventDescriptor descD = new MockEventDescriptor("AIm", "E");
            EventDescriptor descE = new MockEventDescriptor("Boo", "D");
            EventDescriptor descF = new MockEventDescriptor("FOo", "F");

            EventDescriptor [] props = new EventDescriptor [] {
                descA, descB, descC, descD, descE, descF
            };
            descriptors = new EventDescriptorCollection(props);

            Assert.AreSame(descA, descriptors [0], "#A1");
            Assert.AreSame(descB, descriptors [1], "#A2");
            Assert.AreSame(descC, descriptors [2], "#A3");
            Assert.AreSame(descD, descriptors [3], "#A4");
            Assert.AreSame(descE, descriptors [4], "#A5");
            Assert.AreSame(descF, descriptors [5], "#A6");

            sorted = descriptors.Sort(new string [] { "B", "Foo", null, "A", "Boo" },
                                      new CategoryComparer());

            Assert.AreSame(descA, descriptors [0], "#B1");
            Assert.AreSame(descB, descriptors [1], "#B2");
            Assert.AreSame(descC, descriptors [2], "#B3");
            Assert.AreSame(descD, descriptors [3], "#B4");
            Assert.AreSame(descE, descriptors [4], "#B5");
            Assert.AreSame(descF, descriptors [5], "#B6");

            Assert.AreSame(descA, sorted [0], "#C1");
            Assert.AreSame(descE, sorted [1], "#C2");
            Assert.AreSame(descC, sorted [2], "#C3");
            Assert.AreSame(descB, sorted [3], "#C4");
            Assert.AreSame(descD, sorted [4], "#C5");
            Assert.AreSame(descF, sorted [5], "#C6");

            sorted = descriptors.Sort((string [])null, new CategoryComparer());

            Assert.AreSame(descA, descriptors [0], "#D1");
            Assert.AreSame(descB, descriptors [1], "#D2");
            Assert.AreSame(descC, descriptors [2], "#D3");
            Assert.AreSame(descD, descriptors [3], "#D4");
            Assert.AreSame(descE, descriptors [4], "#D5");
            Assert.AreSame(descF, descriptors [5], "#D6");

            Assert.AreSame(descC, sorted [0], "#E1");
            Assert.AreSame(descA, sorted [1], "#E2");
            Assert.AreSame(descB, sorted [2], "#E3");
            Assert.AreSame(descE, sorted [3], "#E4");
            Assert.AreSame(descD, sorted [4], "#E5");
            Assert.AreSame(descF, sorted [5], "#E6");

            sorted = descriptors.Sort(new string [] { "B", "Foo", null, "A", "Boo" },
                                      (Comparer)null);

            Assert.AreSame(descA, descriptors [0], "#F1");
            Assert.AreSame(descB, descriptors [1], "#F2");
            Assert.AreSame(descC, descriptors [2], "#F3");
            Assert.AreSame(descD, descriptors [3], "#F4");
            Assert.AreSame(descE, descriptors [4], "#F5");
            Assert.AreSame(descF, descriptors [5], "#F6");

            Assert.AreSame(descA, sorted [0], "#G1");
            Assert.AreSame(descE, sorted [1], "#G2");
            Assert.AreSame(descB, sorted [2], "#G3");
            Assert.AreSame(descD, sorted [3], "#G4");
            Assert.AreSame(descC, sorted [4], "#G5");
            Assert.AreSame(descF, sorted [5], "#G6");

            sorted = descriptors.Sort((string [])null, (Comparer)null);

            Assert.AreSame(descA, descriptors [0], "#H1");
            Assert.AreSame(descB, descriptors [1], "#H2");
            Assert.AreSame(descC, descriptors [2], "#H3");
            Assert.AreSame(descD, descriptors [3], "#H4");
            Assert.AreSame(descE, descriptors [4], "#H5");
            Assert.AreSame(descF, descriptors [5], "#H6");

            Assert.AreSame(descB, sorted [0], "#I1");
            Assert.AreSame(descD, sorted [1], "#I2");
            Assert.AreSame(descC, sorted [2], "#I3");
            Assert.AreSame(descE, sorted [3], "#I4");
            Assert.AreSame(descA, sorted [4], "#I5");
            Assert.AreSame(descF, sorted [5], "#I6");
        }