Esempio n. 1
0
//        [Ignore("Sort ordering is not preserved (unstable) with equal elements (c.f. System.Array.Sort (Array, IComparer)))")]
        public void OrderingIsUnperturbedWithEqualProps()
        {
            ISortDefinition definition = new MutableSortDefinition("Age", false, true);

            TestObject one   = new TestObject("Rick", 19);
            TestObject two   = new TestObject("Balzac", 19);
            TestObject three = new TestObject("Jenny", 19);

            TestObject[] actual   = new TestObject[] { one, two, three };
            TestObject[] expected = new TestObject[] { one /*Rick*/, two /*Balzac*/, three /*Jenny*/ };
            PropertyComparator.Sort(actual, definition);
            for (int i = 0; i < actual.Length; ++i)
            {
                Assert.AreEqual(expected[i].Name, actual[i].Name);
            }
        }
Esempio n. 2
0
        public void Sort()
        {
            ISortDefinition definition = new MutableSortDefinition("NAmE", true, true);

            TestObject one   = new TestObject("Rick", 19);
            TestObject two   = new TestObject("Balzac", 205);
            TestObject three = new TestObject("Jenny", 89);

            TestObject[] actual   = new TestObject[] { one, two, three };
            TestObject[] expected = new TestObject[] { two /*Balzac*/, three /*Jenny*/, one /*Rick*/ };
            PropertyComparator.Sort(actual, definition);
            for (int i = 0; i < actual.Length; ++i)
            {
                Assert.AreEqual(expected[i].Name, actual[i].Name);
            }
        }
Esempio n. 3
0
        public void SortInDescendingOrder()
        {
            ISortDefinition definition = new MutableSortDefinition("NAmE", true, false);

            TestObject one   = new TestObject("Rick", 19);
            TestObject two   = new TestObject("Balzac", 205);
            TestObject three = new TestObject("Jenny", 89);

            TestObject[] actual = new TestObject[] { one, two, three };
            // Rick comes after Jenny comes after Balzac (descending sort order)...
            TestObject[] expected = new TestObject[] { one /*Rick*/, three /*Jenny*/, two /*Balzac*/ };
            PropertyComparator.Sort(actual, definition);
            for (int i = 0; i < actual.Length; ++i)
            {
                Assert.AreEqual(expected[i].Name, actual[i].Name);
            }
        }
Esempio n. 4
0
 public void SortWithNullDefinition()
 {
     Assert.Throws <ArgumentNullException>(() => PropertyComparator.Sort(Type.EmptyTypes, null));
 }