public static void Main(string[] args) { try { XmlConfigurator.Configure(); Log.Info("Init list"); IList <int> list = new LinkedList.LinkedList <int>(); Log.Info("Add 50 item to list"); for (int i = 0; i < 50; i++) { Log.Info("Add value " + i); list.Add(i); } var value = list[1]; Log.Info("value of item with index 1 is " + value); Console.WriteLine(value); } catch (Exception exception) { Log.Error(exception.Message); } }
public void AddTests(int[] arr, int[] expectedArr, int[] values) { LinkedList.LinkedList actual = new LinkedList.LinkedList(arr); LinkedList.LinkedList expected = new LinkedList.LinkedList(expectedArr); actual.Add(values); Assert.AreEqual(expected, actual); }
public static void Main(string[] args) { try { XmlConfigurator.Configure(); Log.Info("Init list"); IList<int> list = new LinkedList.LinkedList<int>(); Log.Info("Add 50 item to list"); for (int i = 0; i < 50; i++) { Log.Info("Add value " + i); list.Add(i); } var value = list[1]; Log.Info("value of item with index 1 is " + value); Console.WriteLine(value); } catch (Exception exception) { Log.Error(exception.Message); } }
public void Add_SeveralElements_ShouldAddElementsCorrectly() { // Arrange var list = new LinkedList.LinkedList<int>(); // Act list.Add(10); list.Add(5); list.Add(3); // Assert Assert.AreEqual(3, list.Count); var items = new List<int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List<int>() { 10, 5 , 3 }); }
public void Remove_SeveralElements_ShouldRemoveElementsCorrectly() { // Arrange var list = new LinkedList.LinkedList<int>(); list.Add(5); list.Add(6); list.Add(7); // Act var elementOne = list.Remove(0); var elementTwo = list.Remove(1); // Assert Assert.AreEqual(5, elementOne); Assert.AreEqual(7, elementTwo); Assert.AreEqual(1, list.Count); var items = new List<int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List<int>() { 6 }); }
public void Add_EmptyList_ShouldAddElement() { // Arrange var list = new LinkedList.LinkedList<int>(); // Act list.Add(5); // Assert Assert.AreEqual(1, list.Count); var items = new List<int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List<int>(){ 5 }); }
public void Remove_OneElement_ShouldMakeListEmpty() { // Arrange var list = new LinkedList.LinkedList<int>(); list.Add(5); // Act var element = list.Remove(0); // Assert Assert.AreEqual(5, element); Assert.AreEqual(0, list.Count); var items = new List<int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List<int>() { }); }
public void IEnumerable_NonGeneric_MultipleElements() { // Arrange var list = new LinkedList.LinkedList<decimal>(); list.Add(6m); list.Add(7.77m); // Act var enumerator = ((IEnumerable)list).GetEnumerator(); var items = new List<object>(); while (enumerator.MoveNext()) { items.Add(enumerator.Current); } // Assert CollectionAssert.AreEqual(items, new List<object>() { 6m, 7.77m }); }
public void IEnumerable_Foreach_MultipleElements() { // Arrange var list = new LinkedList.LinkedList<string>(); list.Add("Five"); list.Add("Six"); list.Add("Seven"); // Act var items = new List<string>(); foreach (var element in list) { items.Add(element); } // Assert CollectionAssert.AreEqual(items, new List<string>() { "Five", "Six", "Seven" }); }
public void ForEach_MultipleElements_ShouldEnumerateElementsCorrectly() { // Arrange var list = new LinkedList.LinkedList<string>(); list.Add("Five"); list.Add("Six"); list.Add("Seven"); // Act var items = new List<string>(); list.ForEach(items.Add); // Assert CollectionAssert.AreEqual(items, new List<string>() { "Five", "Six", "Seven" }); }
public void ForEach_SingleElement_ShouldEnumerateElementsCorrectly() { // Arrange var list = new LinkedList.LinkedList<int>(); list.Add(5); // Act var items = new List<int>(); list.ForEach(items.Add); // Assert CollectionAssert.AreEqual(items, new List<int>() { 5 }); }
public void RemoveLast_SeveralElements_ShouldRemoveElementsCorrectly() { // Arrange var list = new LinkedList.LinkedList<int>(); list.Add(10); list.Add(9); list.Add(8); // Act var element = list.Remove(2); // Assert Assert.AreEqual(8, element); Assert.AreEqual(2, list.Count); var items = new List<int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List<int>() { 10, 9 }); }