public void InsertFirst_Should_Insert_Item_At_First() { var simpleLinkedList = new SimpleLinkedList <int>(1); var secondLinkedList = simpleLinkedList.InsertLast(2); simpleLinkedList.InsertLast(3); var list = simpleLinkedList.ToList(); Assert.Collection(list, i => Assert.Equal(1, i), i => Assert.Equal(2, i), i => Assert.Equal(3, i)); }
public void Test_SimpleLinkedList() { var linkedList = new SimpleLinkedList <int>(); linkedList.Add(0); Assert.IsTrue(linkedList.Count == 1); Assert.IsTrue(linkedList.Contains(0)); Assert.IsFalse(linkedList.Contains(1)); linkedList.Remove(0); Assert.IsTrue(linkedList.Count == 0); linkedList.Add(1); Assert.IsTrue(linkedList.Count == 1); Assert.IsTrue(linkedList.Contains(1)); Assert.IsFalse(linkedList.Contains(0)); linkedList.Clear(); var tempList = new List <int>(); for (int i = 0; i < 1024 * 32; i++) { var v = _random.Next(0, 256); if (_random.Next(0, 2) == 0) { linkedList.Add(v); tempList.Add(v); } else { linkedList.Remove(v); tempList.Remove(v); } } { tempList.Sort(); var tempList2 = linkedList.ToList(); tempList2.Sort(); Assert.IsTrue(CollectionUtilities.Equals(tempList, tempList2)); } }