public static void TestIEnumetator() { var list = new List.List(); int from = 0; int to = 4; for (int i = from; i <= to; i++) { list.Add(i); } bool result = false; foreach (var i in list) { result = true; } result = false; foreach (var i in list) { result = true; } Assert.True(result); }
public static void TestAddFirstValue() { var list = new List.List(); int value = 10; list.Add(value); Assert.AreEqual(value, (int)list[0]); }
public void List_Test() { List.List<int> list = new List.List<int>(); for (int i = 0; i < 20; i++) list.Add(i); int sum = 0; foreach (int i in list) sum += i; Assert.IsTrue(sum == 190); }
public static List.List GetListIntegers(this string inputString) { List.List result = new List.List(); for (int i = 0; i < inputString.Length; i++) { if (inputString[i] >= '0' && inputString[i] <= '9') { result.Add((int)inputString[i]); } } return(result); }
public static void TestAddFifyhValues() { var list = new List.List(); int from = 0; int to = 4; for (int i = from; i <= to; i++) { list.Add(i); } Assert.AreEqual(to, (int)list[to]); }
static void RunList() { List.List<int> list = new List.List<int>(); for (int i = 0; i < 20; i++) list.Add(i); foreach (int i in list) Console.WriteLine(i); int[] arr = list.ToArray(); foreach (int i in arr) Console.Write(i + " "); Console.WriteLine(); Console.WriteLine(arr.Length); }
public static void TestCountFourValues() { var list = new List.List(); int from = 0; int to = 3; for (int i = from; i <= to; i++) { list.Add(i); } int expectedResult = to + 1; Assert.AreEqual(expectedResult, list.Count); }
public static void TestAddFourValues() { var list = new List.List(); int from = 0; int to = 3; for (int i = from; i <= to; i++) { list.Add(i); } for (int i = from; i <= to; i++) { Assert.AreEqual(i, (int)list[i]); } }
public static void TestContains() { var list = new List.List(); int from = 0; int to = 3; for (int i = from; i <= to; i++) { list.Add(i); } for (int i = from; i <= to; i++) { Assert.True(list.Contains(i)); } Assert.False(list.Contains(list.Contains(5))); }
public static void TestClear() { var list = new List.List(); int from = 0; int to = 8; for (int i = from; i <= to; i++) { list.Add(i); } list.Clear(); int expectedResult = 0; Assert.AreEqual(expectedResult, list.Count); }
public static void TestRemoveAt() { var list = new List.List(); int from = 0; int to = 4; for (int i = from; i <= to; i++) { list.Add(i); } list.RemoveAt(0); int expectedResult = 4; Assert.AreEqual(expectedResult, list.Count); }