Example #1
0
        public void SortTest1()
        {
            var a = new[] { new EClass(3), new EClass(1), new EClass(0) };
            var l = new EventedList <EClass>(a);

            l.Sort(1, 2, new CEClass());
            Assert.That(l[0].Prop, Is.EqualTo(3));
            Assert.That(l[2].Prop, Is.EqualTo(1));
        }
Example #2
0
        public void BinarySearchTest()
        {
            var l = new EventedList <EClass>(100);
            var r = new Random();

            for (var i = 0; i < 100; i++)
            {
                l.Add(new EClass(r.Next()));
            }
            l.Sort();
            var x = l[27];

            Assert.That(l.BinarySearch(x), Is.EqualTo(27));
            Assert.That(l.BinarySearch(x, new CEClass()), Is.EqualTo(27));
            Assert.That(l.BinarySearch(10, 40, x, new CEClass()), Is.EqualTo(27));
            Assert.That(l.BinarySearch(50, 40, x, new CEClass()), Is.Negative);
        }