Пример #1
0
        public void ValidatesInsertMethod()
        {
            var test = new SortedIntArray();

            test.Add(5);
            test.Add(3);
            test.Insert(0, 4);
            Assert.Equal(3, test[0]);
            Assert.Equal(5, test[1]);
            Assert.Equal(2, test.Count);
        }
Пример #2
0
        public void ValidatesInsertMethodAndInsertsAnElement()
        {
            var test = new SortedIntArray();

            test.Add(5);
            test.Add(3);
            test.Insert(0, 1);
            Assert.Equal(1, test[0]);
            Assert.Equal(3, test[1]);
            Assert.Equal(5, test[2]);
            Assert.Equal(3, test.Count);
        }
Пример #3
0
        public void DoesNotInsertBadElement()
        {
            var test = new SortedIntArray();

            test.Add(3);
            test.Add(5);
            test.Add(3);
            test.Add(2);
            test.Add(2);

            test.Insert(2, 5);
            Assert.Equal(2, test[0]);
            Assert.Equal(2, test[1]);
            Assert.Equal(3, test[2]);
            Assert.Equal(3, test[3]);
            Assert.Equal(5, test[4]);

            Assert.Equal(5, test.Count);
        }
Пример #4
0
        public void ValidatesInsertMethodWhereMoreElementsAreEqual()
        {
            var test = new SortedIntArray();

            test.Add(3);
            test.Add(5);
            test.Add(3);
            test.Add(2);
            test.Add(2);

            test.Insert(2, 2);
            Assert.Equal(2, test[0]);
            Assert.Equal(2, test[1]);
            Assert.Equal(2, test[2]);
            Assert.Equal(3, test[3]);
            Assert.Equal(3, test[4]);
            Assert.Equal(5, test[5]);

            Assert.Equal(6, test.Count);
        }