예제 #1
0
        public void FindIndex_EmptyList_ReturnsNegativeOne()
        {
            var list         = new FixedList <int>();
            var notFoundItem = list.FindIndex(-100);

            Assert.IsTrue(notFoundItem == -1);
        }
예제 #2
0
        public void Append_ReturnsTrue()
        {
            var list   = new FixedList <int>();
            var result = list.Append(10);
            var found  = list.FindIndex(10);

            //Check to see if the size is 1
            Assert.IsTrue(list.CurrentSize == 1);

            //Result should be true
            Assert.IsTrue(result == true);

            // 10 should be the only item in the list
            Assert.IsTrue(found == 0);
        }
예제 #3
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);
        }
예제 #4
0
        public void InsertBefore_SingleItem_Returns_True()
        {
            var list   = new FixedList <int>();
            var result = false;

            result = list.InsertBefore(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);
        }
예제 #5
0
        public void Insert_ReturnsTrue()
        {
            var list   = new FixedList <int>();
            var result = list.Insert(10);

            var firstItem = list.FindIndex(10);


            //Check to see if the size is 1
            Assert.IsTrue(list.CurrentSize == 1);

            //Result should be true
            Assert.IsTrue(result == true);

            //first Item should be at index 0
            Assert.IsTrue(firstItem == 0);
        }
예제 #6
0
        public void Insert_OnFullList_ReturnsFalse()
        {
            var list   = new FixedList <int>(2);
            var result = false;

            result = list.Insert(10);
            result = list.Insert(100);
            result = list.Insert(20);

            var firstIndex = list.FindIndex(100);

            //Last append should return false as
            Assert.IsTrue(result == false);
            Assert.IsTrue(list.CurrentSize == list.MaxSize);

            //first item in list should be at index 0
            Assert.IsTrue(firstIndex == 0);
        }
예제 #7
0
        public void Append_OnFullList_ReturnsFalse()
        {
            var list   = new FixedList <int>(2);
            var result = false;


            result = list.Append(10);
            result = list.Append(100);
            result = list.Append(20);

            var lastIndex = list.FindIndex(100);

            //Last append should return false as
            Assert.IsTrue(result == false);
            Assert.IsTrue(list.CurrentSize == 2);

            //100 should be the last index at 1 for two items
            Assert.IsTrue(lastIndex == 1);
        }
예제 #8
0
        public void InsertBefore_ValueToBeInsertedBeforeNotFound_ReturnsFalse()
        {
            var list   = new FixedList <int>();
            var result = false;

            result = list.InsertBefore(10, 20);
            result = list.InsertBefore(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);
        }
예제 #9
0
        public void InsertBefore_ReturnsTrue()
        {
            var list   = new FixedList <int>();
            var result = false;

            result = list.InsertBefore(10, 20);
            result = list.InsertBefore(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 0(first item in the list)
            Assert.IsTrue(found == 0);
        }
예제 #10
0
        public void InsertBefore_ListIsFull_ReturnsFalse()
        {
            var list   = new FixedList <int>(2);
            var result = false;

            result = list.InsertBefore(10, 20);
            result = list.InsertBefore(20, 120);
            result = list.InsertBefore(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);
        }