Пример #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);
        }
Пример #2
0
        public void SortedArrayListSimpleTest()
        {
            var a = new CKSortedArrayList <int>();

            a.AddRangeArray(12, -34, 7, 545, 12);
            Assert.That(a.AllowDuplicates, Is.False);
            Assert.That(a.Count, Is.EqualTo(4));
            Assert.That(a, Is.Ordered);

            Assert.That(a.Contains(14), Is.False);
            Assert.That(a.IndexOf(12), Is.EqualTo(2));

            object o = 21;

            Assert.That(a.Contains(o), Is.False);
            Assert.That(a.IndexOf(o), Is.LessThan(0));

            o = 12;
            Assert.That(a.Contains(o), Is.True);
            Assert.That(a.IndexOf(o), Is.EqualTo(2));

            o = null;
            Assert.That(a.Contains(o), Is.False);
            Assert.That(a.IndexOf(o), Is.EqualTo(Int32.MinValue));

            int[] arrayToTest = new int[5];
            a.CopyTo(arrayToTest, 1);
            Assert.That(arrayToTest[0], Is.EqualTo(0));
            Assert.That(arrayToTest[1], Is.EqualTo(-34));
            Assert.That(arrayToTest[4], Is.EqualTo(545));
        }