static void Opgave1() { System.Console.WriteLine("\n===== Opgave 1 : MyArrayList =====\n"); MyArrayList al = new MyArrayList(10); System.Console.WriteLine(al); al.Add(2); al.Add(3); al.Add(5); System.Console.WriteLine(al); Console.WriteLine(al.Get(0)); try { Console.WriteLine(al.Get(3)); } catch (MyArrayListIndexOutOfRangeException e) { Console.WriteLine(e.Message); } al.Set(2, 4); System.Console.WriteLine(al); al.Clear(); for (int i = 0; i < 10; i++) { al.Add(i); } al.Set(9, 2); al.Set(7, 2); System.Console.WriteLine(al); Console.WriteLine(al.CountOccurences(2)); }
public void testAddOneElementToList() { var l = new MyArrayList<string>(); l.add("foo"); Assert.AreEqual(l.size(), 1); Assert.AreEqual(l.get(0), "foo"); }
public void CustomCapacityInitTest() { int actualCapacity = 24; MyList<int> List = new MyArrayList<int>(actualCapacity); Assert.AreEqual(List.Count, 0); Assert.AreEqual((List as MyArrayList<int>).Capacity, actualCapacity); }
public void GivenAValue_WhenMyArrayListIsInitialized_ShouldInsertIntoInternalList() { var array = new MyArrayList(1); array.Insert(1); array.ToArray().Should().ContainSingle().And.ContainEquivalentOf(1); }
public void CreateArrayFillItAndCountTheNumbers() { MyArrayList _myArray = new MyArrayList(10); _myArray.add(4); _myArray.add(8); _myArray.add(7); _myArray.add(3); _myArray.add(0); _myArray.add(2); _myArray.add(5); _myArray.add(8); _myArray.add(9); _myArray.add(8); Assert.AreEqual(_myArray.countOccurences(8), 3); Assert.AreEqual(_myArray.countOccurences(1), 0); _myArray.clear(); _myArray.add(4); _myArray.add(1); _myArray.add(7); _myArray.add(3); _myArray.add(0); _myArray.add(2); _myArray.add(5); _myArray.add(1); _myArray.add(9); _myArray.add(1); Assert.AreEqual(_myArray.countOccurences(8), 0); Assert.AreEqual(_myArray.countOccurences(1), 3); }
public void DefaultInitTest() { MyList <int> List = new MyArrayList <int>(); Assert.AreEqual(List.Count, 0); Assert.AreEqual((List as MyArrayList <int>).Capacity, 10); }
public void CreateArrayListAddItemAskForNonaddedIndex() { MyArrayList _myArray = new MyArrayList(2); _myArray.set(1, 6); int test = _myArray.get(0); }
public void FindMaxIndex_WhenMethodCalled_ReturnMaxIndex(int[] actualArray, int expected) { MyArrayList list = new MyArrayList(actualArray); int actual = list.FindIndexOfMaxElem(); Assert.AreEqual(expected, actual); }
public void FindMinElement_WhenMethodCalled_ReturnMaxElement(int[] actualArray, int expected) { MyArrayList list = new MyArrayList(actualArray); int actual = list.FindValueOfMinElem(); Assert.AreEqual(expected, actual); }
public void AddTest(int val, int[] expected) { MyArrayList myAL = new MyArrayList(); myAL.Add(val); Assert.AreEqual(expected, myAL.GetValues()); }
public void GetTest(int[] val, int index, int expected) { MyArrayList myAL = new MyArrayList(val); int actual = myAL.Get(index); Assert.AreEqual(expected, actual); }
public void FindNotExistingElement() { MyList <int> List = new MyArrayList <int>(); List.Add(8); List.Add(61); Assert.AreEqual(List.Find(5), -1); }
public void AddByIndexTest(int val, int idx, int[] arr, int[] expected) { MyArrayList myAL = new MyArrayList(arr); myAL.AddByIndex(val, idx); Assert.AreEqual(expected, myAL.GetValues()); }
private static void Print(MyArrayList list) { foreach (var item in list) { Console.Write(item + " "); } Console.WriteLine(); }
public void CanAddNewItem() { MyArrayList <int> myList = new MyArrayList <int>(); myList.Add(1); Assert.Equal(1, myList[0]); }
public void GetFirstIndexByValue_WhenValue_ReturnIndex(int value, int[] actualArray, int expected) { MyArrayList array = new MyArrayList(actualArray); int actual = array.GetFirstIndexByValue(value); Assert.AreEqual(expected, actual); }
public void ContainTest() { MyList <int> List = new MyArrayList <int>(); List.Add(31); List.Add(9); Assert.AreEqual(List.Contains(31), true); }
public void CustomCapacityInitTest() { int actualCapacity = 24; MyList <int> List = new MyArrayList <int>(actualCapacity); Assert.AreEqual(List.Count, 0); Assert.AreEqual((List as MyArrayList <int>).Capacity, actualCapacity); }
public void ArrayExpansionTest(int[] arr, int[] expected) { MyArrayList la = new MyArrayList(arr); int[] actual = la.ArrayExpansion(); Assert.AreEqual(expected, actual); }
public void AddRangeTest(int[] arr, int index, int[] val, int[] expected) { MyArrayList la = new MyArrayList(arr); la.AddRange(val, index); Assert.AreEqual(expected, la.GetValues()); }
public void ArrayReductionTest(int[] arr, int[] expected) { MyArrayList myAL = new MyArrayList(arr); int[] actual = myAL.ArrayReduction(); Assert.AreEqual(expected, actual); }
public void RemoveByValTest(int[] array, int[] expected, int val) { MyArrayList myAL = new MyArrayList(array); myAL.RemoveByVal(val); int[] actual = myAL.ToArray(); Assert.AreEqual(expected, actual); }
public void AddAllTest(int[] arr, int[] val, int[] expected) { MyArrayList myAL = new MyArrayList(arr); myAL.AddAll(val); Assert.AreEqual(expected, myAL.GetValues()); }
public void NotContainTest() { MyList <int> List = new MyArrayList <int>(); List.Add(31); List.Add(9); Assert.AreEqual(List.Contains(63), false); }
public void SetTest(int[] array, int[] expected, int idx, int val) { MyArrayList myAL = new MyArrayList(array); myAL.Set(idx, val); int[] actual = myAL.ToArray(); Assert.AreEqual(expected, actual); }
public void CreateArrayListOfTwoPutTwoItemsInItAndTryToAddItemThree() { MyArrayList _myArray = new MyArrayList(2); _myArray.add(4); _myArray.add(8); _myArray.add(10); }
public void CreateArrayListOfTwoPutTwoItemsInItAndAskForNumberThree() { MyArrayList _myArray = new MyArrayList(2); _myArray.add(4); _myArray.add(8); int test = _myArray.get(2); }
public void AddTest() { var myArrayList = new MyArrayList <int>(); myArrayList.Add(58); myArrayList.Add(48); Assert.AreEqual(2, myArrayList.Count); }
public void Should_add_element() { var arrayList = new MyArrayList(); var insertedIndex = arrayList.Add(5); Assert.Equal(0, insertedIndex); Assert.Single(arrayList); }
public void CopyConstructorTest() { MyList<int> List = new MyArrayList<int>(); List.Add(1); List.Add(2); MyList<int> List2 = new MyArrayList<int>(List); Assert.AreEqual(List2, List); }
public void SetUp() { list = new MyArrayList( ); list.Add(1); list.Add(2); list.Add(3); list.Add(4); }
public void ClearTest() { MyList<int> List = new MyArrayList<int>(); List.Add(1); List.Add(2); List.Clear(); Assert.AreEqual(List.Count, 0); Assert.AreEqual((List as MyArrayList<int>).Capacity, 10); }
public void CreateArrayListOfTwoAndPutTwoItemsInIt() { MyArrayList _myArray = new MyArrayList(2); _myArray.add(4); _myArray.add(8); Assert.AreEqual(_myArray.get(0), 4); Assert.AreEqual(_myArray.get(1), 8); }
public void AddTest() { int actualValue = 38; MyList<int> List = new MyArrayList<int>(); List.Add(actualValue); Assert.AreEqual(List.Count, 1); Assert.AreEqual(List[0], actualValue); }
public override List <DeviceFieldForUI> getDeviceFocusFields() { Dictionary <string, DeviceFieldForUI> map = this.getBaseInfoFields(); var list = new MyArrayList <DeviceFieldForUI>(); list.Add(getBaseInfoFields()[KEY_POINT_RUN_DAYS]); list.Add(getBaseInfoFields()[KEY_POINT_RUN_HOURS]); return(list); }
public void AddMoreThanCapacityTest() { int actualCapacity = 1; int actualValue = 52; MyList<int> List = new MyArrayList<int>(actualCapacity); List.Add(1); List.Add(actualValue); Assert.AreEqual(List.Count, 2); Assert.AreEqual((List as MyArrayList<int>).Capacity, actualCapacity + 10); Assert.AreEqual(List[1], actualValue); }
public void CustomCapacityLessThanZeroInitTest() { int actualCapacity = -83; try { MyList<int> List = new MyArrayList<int>(actualCapacity); } catch(ArgumentOutOfRangeException e) { StringAssert.Contains(e.Message, "Вместимость списка должна быть натуральным числом."); } }
public void testListExpansion() { var l = new MyArrayList<string>(); for (int i = 0; i < 200; i++) { l.add("str#" + i); } int index = 0; foreach (var it in l) { Assert.AreEqual(it,"str#" + index); index++; } }
public void testEnumerator() { var l = new MyArrayList<string>(); l.add("i'll be back"); l.add("i'm gona fail mother f****r"); var enumerator = l.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(enumerator.Current, "i'll be back"); Assert.IsTrue(enumerator.MoveNext()); Assert.AreEqual(enumerator.Current, "i'm gona fail mother f****r"); Assert.IsFalse(enumerator.MoveNext()); }
public void RemoveExistingElementTest() { MyList<int> List = new MyArrayList<int>(); List.Add(75); List.Add(57); List.Add(50); Assert.AreEqual(List.Remove(57), true); Assert.AreEqual(List.Contains(57), false); }
public void InsertMoreThanRangeTest() { MyList<int> List = new MyArrayList<int>(); List.Add(55); List.Add(41); List.Insert(79, 10); Assert.AreEqual(List[2], 79); }
public void InsertTest() { MyList<int> List = new MyArrayList<int>(); List.Add(55); List.Add(41); List.Insert(79, 1); Assert.AreEqual(List[1], 79); }
public void GetElementOutOfRange() { MyList<int> List = new MyArrayList<int>(); List.Add(52); List.Add(95); try { List.Get(2); } catch (IndexOutOfRangeException e) { StringAssert.Contains(e.Message, "Индекс вне диапазона."); } }
public void testSetOnEmptyList() { var l = new MyArrayList<string>(); l.set(0, "i'm gona fail mother f****r"); }
public void testRemoveSingle() { var l = new MyArrayList<string>(); l.add("foo"); l.remove(0); Assert.AreEqual(l.size(), 0); }
public void NotContainTest() { MyList<int> List = new MyArrayList<int>(); List.Add(31); List.Add(9); Assert.AreEqual(List.Contains(63), false); }
public void testGetNegative() { var l = new MyArrayList<string>(); l.add("str 1"); l.get(-1); }
public void testGetOnEmptyList() { var l = new MyArrayList<string>(); l.get(0); }
public void testRemoveOutOfRange() { var l = new MyArrayList<string>(); l.remove(100); }
public void testRemoveInTheMiddleOfTheList() { var l = new MyArrayList<string>(); l.add("foo"); l.add("bar"); l.add("biz"); l.remove(1); Assert.AreEqual(l.size(), 2); Assert.AreEqual(l.get(0), "foo"); Assert.AreEqual(l.get(1), "biz"); }
public void testNewListIsEmpty() { var l = new MyArrayList<string>(); Assert.AreEqual(l.size(), 0); }
public void FindNotExistingElement() { MyList<int> List = new MyArrayList<int>(); List.Add(8); List.Add(61); Assert.AreEqual(List.Find(5), -1); }
public void testSetOnOutOfRange() { var l = new MyArrayList<string>(); l.add("i'll be back"); l.set(1, "i'm gona fail mother f****r"); }
public void GetElementInRange() { MyList<int> List = new MyArrayList<int>(); List.Add(52); List.Add(95); Assert.AreEqual(List.Get(0), 52); Assert.AreEqual(List.Get(1), 95); }
public void DefaultInitTest() { MyList<int> List = new MyArrayList<int>(); Assert.AreEqual(List.Count, 0); Assert.AreEqual((List as MyArrayList<int>).Capacity, 10); }
public void testGetOnOutOfRange() { var l = new MyArrayList<string>(); l.add("str 1"); l.get(1); }
public void ContainTest() { MyList<int> List = new MyArrayList<int>(); List.Add(31); List.Add(9); Assert.AreEqual(List.Contains(31), true); }
public void CopyToArray() { int[] array = new int[2]; MyList<int> List = new MyArrayList<int>(); List.Add(51); List.Add(94); List.CopyTo(array, 0); Assert.AreEqual(array[0], 51); Assert.AreEqual(array[1], 94); }
public void InvalidCopyToArray() { int[] array = new int[2]; MyList<int> List = new MyArrayList<int>(); List.Add(51); List.Add(94); try { List.CopyTo(array, 2); } catch (IndexOutOfRangeException e) { StringAssert.Contains(e.Message, "Индекс вне диапазона."); } }
public void testSetOneElement() { var l = new MyArrayList<string>(); l.add("foo"); Assert.AreEqual(l.size(), 1); l.set(0, "bar"); Assert.AreEqual(l.get(0), "bar"); }