Ejemplo n.º 1
0
        public void SortedArrayListSimpleTest()
        {
            var a = new CKSortedArrayList <int>();

            a.AddRangeArray(12, -34, 7, 545, 12);
            a.AllowDuplicates.Should().BeFalse();
            a.Count.Should().Be(4);
            a.Should().BeInAscendingOrder();

            a.Contains(14).Should().BeFalse();
            a.IndexOf(12).Should().Be(2);

            object o = 21;

            a.Contains(o).Should().BeFalse();
            a.IndexOf(o).Should().BeLessThan(0);

            o = 12;
            a.Contains(o).Should().BeTrue();
            a.IndexOf(o).Should().Be(2);

            o = null;
            a.Contains(o).Should().BeFalse();
            a.IndexOf(o).Should().Be(int.MinValue);

            int[] arrayToTest = new int[5];
            a.CopyTo(arrayToTest, 1);
            arrayToTest[0].Should().Be(0);
            arrayToTest[1].Should().Be(-34);
            arrayToTest[4].Should().Be(545);
        }
Ejemplo n.º 2
0
        public void SortedArrayListAllowDuplicatesTest()
        {
            var b = new CKSortedArrayList <int>(true);

            b.AddRangeArray(12, -34, 7, 545, 12);
            b.AllowDuplicates.Should().BeTrue();
            b.Count.Should().Be(5);
            b.Should().BeInAscendingOrder();
            b.IndexOf(12).Should().Be(2);
            b.CheckPosition(2).Should().Be(2);
            b.CheckPosition(3).Should().Be(3);
        }