Exemple #1
0
        public void InsertedElementCanBeRetrieved()
        {
            LinkedList list = new LinkedList();

            int testValue = 1;
            list.Add(testValue);

            int lastAddedItem = list.Last();

            Assert.AreEqual(testValue, lastAddedItem);
        }
Exemple #2
0
        public void InsertedLowerElementIsNotLast()
        {
            LinkedList list = new LinkedList();

            int testValue = 5;
            int smallerTestValue = 3;

            list.Add(testValue);
            list.Add(smallerTestValue);

            int lastAddedItem = list.Last();

            Assert.AreEqual(testValue, lastAddedItem);
        }
Exemple #3
0
        public void InsertedMultipleItemsAreSorted()
        {
            LinkedList list = new LinkedList();

            int[] values = { 5, 3, 4, 0 };

            foreach (int val in values)
            {
                list.Add(val);
            }

            Array.Sort(values);

            int counter = 0;

            foreach(var item in list.Next()) {
                Assert.AreEqual(values[counter], item.Value);
                counter++;
            }
        }
Exemple #4
0
 public void LastOneEmptyListThrowsInvalidOperation()
 {
     LinkedList list = new LinkedList();
     Assert.Throws(typeof(InvalidOperationException), () => list.Last());
 }