예제 #1
0
        public void InsertAfter_ReturnsTrue()
        {
            var list   = new FixedList <int>();
            var result = false;

            result = list.InsertAfter(10, 20);
            result = list.InsertAfter(20, 10);

            var found = list.FindIndex(10);

            //check the currentSize should be two
            Assert.IsTrue(list.CurrentSize == 2);

            //check for result to be true
            Assert.IsTrue(result == true);

            //index of 10 should be 1(last item in the list)
            Assert.IsTrue(found == 1);
        }
예제 #2
0
        public void InsertAfter_ValueToBeInsertedAfterNotFound_ReturnsFalse()
        {
            var list   = new FixedList <int>();
            var result = false;

            result = list.InsertAfter(10, 20);
            result = list.InsertAfter(120, 10);

            var found = list.FindIndex(120);

            //check the currentSize should be one
            Assert.IsTrue(list.CurrentSize == 1);

            //check for result to be true
            Assert.IsTrue(result == false);

            //index of 120 should be -1 not found
            Assert.IsTrue(found == -1);
        }
예제 #3
0
        public void InsertAfter_ListIsFull_ReturnsFalse()
        {
            var list   = new FixedList <int>(2);
            var result = false;

            result = list.InsertAfter(10, 20);
            result = list.InsertAfter(20, 120);
            result = list.InsertAfter(120, 40);

            var found = list.FindIndex(40);

            //check the currentSize should be MaxSize
            Assert.IsTrue(list.CurrentSize == list.MaxSize);

            //check for result to be true
            Assert.IsTrue(result == false);

            //index of 120 should be -1 not found
            Assert.IsTrue(found == -1);
        }
예제 #4
0
        public void FindIndex_ItemFound_ReturnsIndexOfFoundItem()
        {
            var list = new FixedList <int>();

            list.Append(10);
            list.Append(100);
            list.Insert(45);
            list.InsertAfter(45, 60);
            list.InsertBefore(60, 85);

            //85 should be the second item
            var foundItem = list.FindIndex(85);

            Assert.IsTrue(foundItem == 1);
        }
예제 #5
0
        public void InsertAfter_SingleItem_Returns_True()
        {
            var list   = new FixedList <int>();
            var result = false;

            result = list.InsertAfter(10, 20);
            var found = list.FindIndex(20);

            //check the currentSize should be one
            Assert.IsTrue(list.CurrentSize == 1);
            Assert.IsTrue(result == true);

            //index of 10 should be 0(first item in the list)
            Assert.IsTrue(found == 0);
        }