public void ArrayInitializers() { var tl1 = new TripleList<int>() { 5, 10, 15 }; Assert.AreEqual(3, tl1.Count()); var tl2 = new TripleList<int>() { 0, tl1, 20 }; Assert.AreEqual(3, tl1.Count()); Assert.AreEqual(5, tl2.Count()); Assert.AreEqual(tl1.Value, tl2.MiddleElement.Value); var tl1Sorted = tl1.ToList(); tl1Sorted.Sort(); var tl2Sorted = tl2.ToList(); tl2Sorted.Sort(); Enumerable.SequenceEqual(tl1Sorted, tl2Sorted); }
public void TestAddingTreeElements() { TripleList<int> tripleList = new TripleList<int>(); int value1 = 4; int value2 = -9; int value3 = 47; tripleList.Add(value1); tripleList.Add(value2); tripleList.Add(value3); Assert.AreEqual(3, tripleList.Count()); // checking values Assert.AreEqual(value1, tripleList.Value); Assert.AreEqual(value2, tripleList.MiddleElement.Value); Assert.AreEqual(value3, tripleList.NextElement.Value); // checking neighbour Nodes of first element Assert.IsNull(tripleList.PreviousElement); Assert.IsNotNull(tripleList.MiddleElement); Assert.IsNotNull(tripleList.NextElement); // checking neighbour Nodes of second element Assert.IsNull(tripleList.MiddleElement.PreviousElement); Assert.IsNotNull(tripleList.MiddleElement.MiddleElement); Assert.IsNull(tripleList.MiddleElement.NextElement); // checking neighbour Nodes of third/last element Assert.IsNotNull(tripleList.NextElement.PreviousElement); Assert.IsNull(tripleList.NextElement.MiddleElement); Assert.IsNull(tripleList.NextElement.NextElement); // checking values Assert.AreEqual(value1, tripleList.Value); Assert.AreEqual(value2, tripleList.MiddleElement.Value); Assert.AreEqual(value3, tripleList.NextElement.Value); }
public void TestEmptyListCreation() { TripleList<int> tripleList = new TripleList<int>(); Assert.AreEqual(0, tripleList.Count()); Assert.IsNull(tripleList.PreviousElement); Assert.IsNull(tripleList.MiddleElement); Assert.IsNull(tripleList.NextElement); }
public void TestAddingSingleElement() { TripleList<int> tripleList = new TripleList<int>(); const int value = 4; tripleList.Add(value); Assert.AreEqual(1, tripleList.Count()); Assert.AreEqual(value, tripleList.Value); Assert.IsNull(tripleList.PreviousElement); Assert.IsNull(tripleList.MiddleElement); Assert.IsNull(tripleList.NextElement); }
public void TestAddingFiveElements() { TripleList<int> tripleList = new TripleList<int>(); int value1 = 1; int value2 = 2; int value3 = 3; int value4 = 4; int value5 = 5; tripleList.Add(value1); tripleList.Add(value2); tripleList.Add(value3); tripleList.Add(value4); tripleList.Add(value5); Assert.AreEqual(5, tripleList.Count()); // checking values Assert.AreEqual(value1, tripleList.Value); Assert.AreEqual(value2, tripleList.MiddleElement.Value); Assert.AreEqual(value3, tripleList.NextElement.Value); Assert.AreEqual(value4, tripleList.NextElement.MiddleElement.Value); Assert.AreEqual(value5, tripleList.NextElement.NextElement.Value); }