Esempio n. 1
0
        public void FailOnOperationsWithInvalidNode()
        {
            var invalidNode = new OneWayListNode <int>(new OneWayList <int>(), 12);
            var sut         = new OneWayList <int>(iarray);

            // Assert
            Assert.Throws <InvalidOperationException>(() => sut.Delete(invalidNode));
            Assert.Throws <InvalidOperationException>(() => sut.InsertAfter(invalidNode, 12));
        }
Esempio n. 2
0
        public void DeleteInMiddle()
        {
            int[] input     = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int[] expOutput = new int[] { 1, 2, 3, 4, 6, 7, 8, 9, 10 };

            var sut = new OneWayList <int>(input);

            int index   = 5;
            var remNode = sut.Head;

            while (--index > 0)
            {
                remNode = remNode.Next;
            }


            sut.Delete(remNode);
            // Assert
            Assert.AreEqual(expOutput, sut.ToArray());
            Assert.AreEqual(expOutput.Count(), sut.Count);
        }