예제 #1
0
        public void InsertElementAtOutOfBoundsPositionThrowsException()
        {
            //Arrange
            var l = new SingleLinkedList <int>();

            l.AddLast(1);
            l.AddLast(2);
            l.AddLast(3);
            l.AddLast(4);

            //Act
            //Assert
            Assert.Throws <ArgumentException>(() => l.AddAtPosition(9, 6));
        }
예제 #2
0
        public void InsertElementAtLastPosition()
        {
            //Arrange
            var l = new SingleLinkedList <int>();

            l.AddLast(1);
            l.AddLast(2);
            l.AddLast(3);
            l.AddLast(4);

            //Act
            l.AddAtPosition(9, 5);

            //Assert
            Assert.AreEqual(l.Contains(9), true);
            Assert.AreEqual(l.GetElementPosition(9), 5);
        }