public void AddSingleElem() { var exp = new List <int>() { 5 }; var insertAlgo = new InsertSortedIntoSingleLinkedList(); insertAlgo.InsertSorted(5); var result = insertAlgo.GetValues(); Assert.That(result.SequenceEqual(exp), Is.True); }
public void Test1() { var items = new List <int> { 10, 7, 2, 5, 15 }; var exp = new List <int> { 2, 5, 7, 10, 15 }; var insertAlgo = new InsertSortedIntoSingleLinkedList(); foreach (var n in items) { insertAlgo.InsertSorted(n); } var actual = insertAlgo.GetValues(); Assert.That(actual.SequenceEqual(exp), Is.True); }
public void AddInTheMiddle() { var exp = new List <int>() { 2, 5, 7, 8 }; var insertAlgo = new InsertSortedIntoSingleLinkedList(); insertAlgo.InsertSorted(5); insertAlgo.InsertSorted(2); insertAlgo.InsertSorted(8); // Act insertAlgo.InsertSorted(7); var result = insertAlgo.GetValues(); Assert.That(result.SequenceEqual(exp), Is.True); }