public void AddSingleElementIntoEmptyCollection()
        {
            var list = new SingleIndexedLinkedList<int>();

            list.Add(3);

            Assert.AreEqual(1, list.Count, MESSAGE_COUNTNOTMATCHING);
            Assert.AreEqual(0, list.FirstIndexOf(3), MESSAGE_FIRSTINDEXOF);
            Assert.AreEqual(0, list.LastIndexOf(3), MESSAGE_LASTINDEXOF);
        }
        public void AddMultipleElementsWithoutRepetitions()
        {
            var list = new SingleIndexedLinkedList<int>();

            list.Add(4);
            list.Add(58);
            list.Add(659816519);
            list.Add(165965);

            Assert.AreEqual(4, list.Count, MESSAGE_COUNTNOTMATCHING);
            Assert.AreEqual(2, list.FirstIndexOf(659816519), MESSAGE_FIRSTINDEXOF);
            Assert.AreEqual(3, list.FirstIndexOf(165965), MESSAGE_FIRSTINDEXOF + " Item at last index.");
            Assert.AreEqual(2, list.LastIndexOf(659816519), MESSAGE_LASTINDEXOF);
        }
        public void RemoveElementAtIndexZero()
        {
            var list = new SingleIndexedLinkedList<int>();

            list.Add(4);
            list.Add(58);
            list.Add(659816519);
            list.Add(165965);

            list.Remove(0);

            Assert.AreEqual(3, list.Count, MESSAGE_COUNTNOTMATCHING);
            Assert.AreEqual(-1, list.FirstIndexOf(4), MESSAGE_FIRSTINDEXOF);
            Assert.AreEqual(2, list.FirstIndexOf(165965), MESSAGE_FIRSTINDEXOF);
            Assert.AreEqual(-1, list.LastIndexOf(4), MESSAGE_LASTINDEXOF);

            var expectedList = this.FillIntoList(list);
            CollectionAssert.AreEqual(expectedList, new List<int>() { 58, 659816519, 165965 }, "Elements' order is not correct.");
        }
        public void RemoveElementFromEmptyList()
        {
            var list = new SingleIndexedLinkedList<int>();

            list.Remove(2);
        }
        private List<int> FillIntoList(SingleIndexedLinkedList<int> linkedList)
        {
            var list = new List<int>();

            foreach (var item in linkedList)
            {
                list.Add(item);
            }

            return list;
        }
        public void RemovingTailShouldAllowCorrectAddingAfterwards()
        {
            var list = new SingleIndexedLinkedList<int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Add(5);
            list.Add(6);
            list.Add(7);

            list.Remove(2);
            list.Remove(3);
            list.Remove(4);
            list.Add(8);
            list.Add(9);

            Assert.AreEqual(6, list.Count, MESSAGE_COUNTNOTMATCHING);

            var items = FillIntoList(list);
            CollectionAssert.AreEqual(new List<int>() { 1, 2, 4, 6, 8, 9 }, items, "Adding items after tail has been removed should work correctly.");
        }
        public void RemoveRepetitiveElementFromListWithRepetitions()
        {
            var list = new SingleIndexedLinkedList<int>();

            list.Add(4);
            list.Add(58);
            list.Add(659816519);
            list.Add(165965);
            list.Add(659816519);
            list.Add(165965);

            list.Remove(2);

            Assert.AreEqual(5, list.Count, MESSAGE_COUNTNOTMATCHING);
            Assert.AreEqual(1, list.FirstIndexOf(58), MESSAGE_FIRSTINDEXOF);
            Assert.AreEqual(1, list.LastIndexOf(58), MESSAGE_LASTINDEXOF);
            Assert.AreEqual(3, list.FirstIndexOf(659816519), MESSAGE_FIRSTINDEXOF);
            Assert.AreEqual(3, list.LastIndexOf(659816519), MESSAGE_LASTINDEXOF);

            var expectedList = this.FillIntoList(list);
            CollectionAssert.AreEqual(expectedList, new List<int>() { 4, 58, 165965, 659816519, 165965 }, "Elements' order is not correct.");
        }