public void RemoveMethod_ShouldReturnCorrectIndex()
        {
            int number = list.Remove(2);

            Assert.That(number.Equals(1),
                        "RemoveAt method doesn't return the correct index!");
        }
Exemple #2
0
        public void RemoveMethodShouldRemoveTheCorrectItem()
        {
            int index = intList.Remove(6);

            Assert.AreEqual(1, index);
            Assert.AreEqual(4, intList.Count);
            Assert.That(!intList.Contains(6));
        }
        public void RemoveMethodShouldReturnCorrectIndexIfElementIsRemoved()
        {
            dynamicList.Add(3);
            dynamicList.Add(4);
            dynamicList.Add(5);
            int removedIndex = dynamicList.Remove(3);

            Assert.That(removedIndex, Is.EqualTo(0));
        }
Exemple #4
0
        public void Remove_NonExistantItem_ShouldReturnNegativeOne()
        {
            list.Add(4);
            list.Add(5);

            int actual   = list.Remove(100);
            int expected = -1;

            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void TestRemoveItemsByValue()
        {
            var actualList = new DynamicList <int> {
                3, 4, 5, 6, 8
            };
            var expectedListAfterRemovindByIndex = new DynamicList <int> {
                3, 4, 5
            };

            actualList.Remove(6);
            actualList.Remove(8);

            CollectionAssert.AreEqual(expectedListAfterRemovindByIndex, actualList);
        }
Exemple #6
0
        public void RemovePass(int value)
        {
            DynamicList <int> dynamicList = new DynamicList <int>();

            dynamicList.Add(10);
            Assert.AreEqual(0, dynamicList.Remove(value));
        }
Exemple #7
0
        public void IndexOfNotPass(int value)
        {
            DynamicList <int> dynamicList = new DynamicList <int>();

            dynamicList.Add(10);
            Assert.AreEqual(-1, dynamicList.Remove(value));
        }
Exemple #8
0
        public DynamicListTest()
        {
            Console.WriteLine("\nDynamic List");
            _dynamicList.Add(1);
            _dynamicList.Add(2);
            _dynamicList.Add(3);
            _dynamicList.Add(4);
            _dynamicList.Add(5);
            _dynamicList.Add(6);
            _dynamicList.Add(7);

            int[] array = _dynamicList.Items;
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(array[i] + " ");
            }
            Console.WriteLine("\nSize = " + _dynamicList.Count);

            _dynamicList.RemoveAt(1);
            _dynamicList.Remove(3);

            var s = _dynamicList.GetEnumerator();

            while (s.MoveNext())
            {
                Console.Write(s.Current + " ");
            }
            _dynamicList.Clear();
            Console.WriteLine("\nSize = " + _dynamicList.Count);
        }
Exemple #9
0
        public void Remove_NullElementInExistingList_ShouldThrowExcepion()
        {
            var stringList = new DynamicList <string>();

            stringList.Add("Pesho");
            stringList.Remove(null);
        }
        public void TestRemove_NotExistingElement_ShouldNeutralIndex()
        {
            var list = new DynamicList<int>();

            var index = list.Remove(1);
            Assert.AreEqual(-1, index);
        }
        public void RemoveAndRemoveAtTest()
        {
            DynamicList<int> numbers = new DynamicList<int>();
            numbers.Add(5);
            numbers.Add(7);
            numbers.Add(9);

            numbers.Remove(5);
            Assert.IsFalse(numbers.Contains(5), "Remove method doesn't work correctly.");

            numbers.RemoveAt(1);
            Assert.AreEqual(-1, numbers.IndexOf(9), "RemoveAt method doesn't work correctly.");

            Assert.AreEqual(-1, numbers.Remove(13), "Error when trying to remove unexisting item.");

            Assert.AreEqual(0, numbers.Remove(7), "Wrong return value of remove method.");
        }
Exemple #12
0
        public void RemoveTest()
        {
            for (var i = 4; i > 0; i--)
            {
                _list.Add(i);
            }

            bool removed = _list.Remove(2);

            Assert.That(removed, Is.True);

            Assert.That(_list.Count, Is.EqualTo(3));
            Assert.That(_list.Items, Is.EqualTo(new int[] { 4, 3, 1 }));

            removed = _list.Remove(2);
            Assert.That(removed, Is.False);
        }
        public void TestRemoveMethod_WithNonExistingObject_ShouldReturnNegativeValue()
        {
            DynamicList<int> arr = new DynamicList<int>();
            arr.Add(1);
            arr.Add(2);

            Assert.AreEqual(-1, arr.Remove(3), "The Remove method shuld not remove non-existing objects!");
        }
        public void Count_MultipleAddAndRemove_ShouldProperCount()
        {
            var list = new DynamicList<int>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(i);
                list.Add(i);
                list.Remove(i);
            }

            var index = list.Remove(9);
            var count = list.Count;

            Assert.AreEqual(9, count);
            Assert.AreEqual(9, index);
        }
        public void RemovingNoneExistingElementFromNoneEmptyDynamicListOfIntsShouldReturnMinusOne()
        {
            var dynamicListOfInts = new DynamicList<int>();
            dynamicListOfInts.Add(1);

            var returnedValue = dynamicListOfInts.Remove(9);

            Assert.AreEqual(-1, returnedValue, string.Format("The method \"Remove\" does not work correctly when removing none existing number.\nShould return -1!" + string.Format("returned value is {0}", returnedValue)));
        }
 public void Count_SingleAddAndRemove_ShouldProperCount()
 {
     var list = new DynamicList<int>();
     list.Add(5);
     var index = list.Remove(5);
     var count = list.Count;
     Assert.AreEqual(0, count);
     Assert.AreEqual(0, index);
 }
Exemple #17
0
        public void TestRemoveWhenListIsEmptyOrNotFound()
        {
            var dynamicList = new DynamicList<int>();

            // Act
            var removedElementIndex = dynamicList.Remove(1);

            // Assert
            Assert.IsTrue(removedElementIndex < 0, "List in not empty or not found");
        }
  public void TestRemoveMethod_AddingAndRemovingObjects()
  {
      DynamicList<int> arr = new DynamicList<int>();
      arr.Add(1);
      arr.Add(2);
      arr.Add(3);
      arr.Add(4);
 
      arr.Remove(1);
      Assert.AreEqual(3,arr.Count,"The removing method doesn't work correclty!");
  }
        public void TestCountAfterRemoveElementFromList()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");
            list.Add("third");

            list.Remove("second");
            int count = list.Count;

            Assert.AreEqual(2, count, "The count of elements of the list should be 2 after removing an element.");
        }
        public void TestCountAfterRemoveExistingElement()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");
            list.Add("third");
            int countBeforeRemoving = list.Count;

            list.Remove("second");
            int countAfterRemoving = list.Count;

            Assert.AreEqual(countAfterRemoving+1, countBeforeRemoving, "Count after removing must be less by 1.");
        }
Exemple #21
0
        public void TestRemove()
        {
            var dynamicList = new DynamicList<int>();
            var elementForRemove = 2;
            dynamicList.Add(0);
            dynamicList.Add(elementForRemove);
            dynamicList.Add(4);

            // Act
            var removedElementIndex = dynamicList.Remove(elementForRemove);

            // Assert
            Assert.AreEqual(dynamicList[1], 4, "Element for remove not removed.");
            Assert.AreEqual(2, dynamicList.Count, "Dynamic list not remove element.");
        }
        public void IndexationTest()
        {
            DynamicList<double> nums = new DynamicList<double>();
            nums.Add(2.5);
            nums.Add(4);
            nums.Add(-100);

            Assert.AreEqual(2.5, nums[0], "Error in the indexation");
            Assert.AreEqual(4, nums[1], "Error in the indexation");

            nums.Remove(4);
            Assert.AreEqual(-100, nums[1], "Error in the indexation");

            nums[1] = 250.5;
            Assert.AreEqual(250.5, nums[1], "Error in the indexation");
        }
Exemple #23
0
        public void RemoveElement_ElementSuccessfullyRemoved()
        {
            var dynamicList = new DynamicList<int>();

            const int firstElement = 666;
            const int secondElement = 777;
            dynamicList.Add(firstElement);
            dynamicList.Add(secondElement);

            dynamicList.Remove(firstElement);

            Assert.AreEqual(1, dynamicList.Count, "The collection's lenght is not 1!");
            Assert.AreEqual(secondElement, dynamicList[0], "The collection's element does not equal the element it should be equal to!");
        }
        public void Remove_ShouldRemoveTheElement_WhenCalled()
        {
            var dynamicList = new DynamicList<int>();
            dynamicList.Add(1);
            dynamicList.Add(5);

            dynamicList.Remove(5);

            Assert.AreEqual(dynamicList.Count, 1, "The method .Remove isn't removing the element properly.");
        }
        public void Remove_ShouldReturnMinusOneWhenTheElementIsNotFound()
        {
            var dynamicList = new DynamicList<string>();
            dynamicList.Add("Kori");
            dynamicList.Add("Moti4kata");
            dynamicList.Add("allahuakbar");

            var returnedValue = dynamicList.Remove("Kiro");
            Assert.AreEqual(-1,returnedValue, "The method .Remove isn't removing the element properly.");
        }
        public void TestList_Count_AfterRemoveElement()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("one");
            list.Add("two");
            list.Add("three");

            list.Remove("two");
            int count = list.Count;

            Assert.AreEqual(2, count, "The count of elements of the list should be 2 after removing an element.");
        }
        public void Test_ValueAndOrderOfLeftElementsAfterRemovingAnElement()
        {
            var list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");
            list.Add("third");

            list.Remove("second");
            var first = list[0];
            var second = list[1];

            Assert.AreEqual("first", first, "The first element of the list should be the first one entered.");
            Assert.AreEqual(
                "third", 
                second, 
                "The second element in the list should be the third one entered after removing an element.");
        }
        public void TestValidListItemsAfterRemove()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");
            list.Add("third");

            list.Remove("second");
            string first = list[0];
            string second = list[1];

            Assert.AreEqual("first", first, "The first element of the list should be the first one entered.");
            Assert.AreEqual("third", second, "The second element in the list should be the third one entered after removing an element.");
        }
        public void TestReturnValueAfterRemoveElementFromList()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");
            list.Add("third");

            int index = list.Remove("second");

            Assert.AreEqual(1, index, "The index of the removed element should be 1.");
        }
        public void Remove_RemoveItem_ShouldDecrementCount()
        {
            var list = new DynamicList<int>();
            list.Add(5);
            list.Add(6);
            list.Add(7);

            list.Remove(6);
            var expected = 2;
            var actual = list.Count;

            Assert.AreEqual(expected, actual);
        }
        public void Remove_RemoveItem_ShloudRemoveSelectedItem()
        {
            var list = new DynamicList<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);

            list.Remove(2);

            var expected = -1;
            var actual = list.IndexOf(2);

            Assert.AreEqual(expected, actual);
        }
        public void Remove_NotFound_ShloudReturnNegativeOne()
        {
            var list = new DynamicList<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);

            var expected = -1;
            var actual = list.Remove(34);
            Assert.AreEqual(expected, actual);
        }
        public void Test_ReturnedIndexOfTheRemovedElement()
        {
            var list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");
            list.Add("third");

            var index = list.Remove("second");

            Assert.AreEqual(1, index, "The index of the removed element should be 1.");
        }
Exemple #34
0
        public void RemoveExistingElement_Successful()
        {
            var dynamicList = new DynamicList<int>();

            const int firstElement = 666;
            const int secondElement = 777;
            dynamicList.Add(firstElement);
            dynamicList.Add(secondElement);

            var getElement = dynamicList.Remove(firstElement);

            Assert.AreEqual(0, getElement, "The returned element is not correct!");
        }
Exemple #35
0
        public void RemoveNonExistingElement_NotSuccessful()
        {
            var dynamicList = new DynamicList<int>();

            const int firstElement = 666;
            const int secondElement = 777;
            const int randomNumber = 9067576;
            dynamicList.Add(firstElement);
            dynamicList.Add(secondElement);

            var getElement = dynamicList.Remove(randomNumber);

            Assert.AreEqual(-1, getElement, "The returned element is not correct!");
        }
 public void Test_CountAfterRemoveNonExistingElementFromList()
 {
     var list = new DynamicList<string>();
     list.Add("one");
     list.Add("two");
     var count = list.Count;
     list.Remove("two");
     Assert.AreEqual(
         2, 
         count, 
         "The count of the list should remain unchanged after trying to remove a non-existing element.");
 }
        public void TestReturnValueAfterRemoveNonExistingElementFromList()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("one");
            list.Add("two");
            int index = list.Remove("three");

            Assert.AreEqual(-1, index, "The returned index of a non-existing element should be -1.");
        }
        public void RemoveTest()
        {
            DynamicList<int> list = new DynamicList<int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);

            list.Remove(3);

            Assert.IsFalse(list.Contains(3), "List does not remove items correctly");
        }
        public void Remove_FromEmptyList_ShouldReturnNegativeOne()
        {
            var list = new DynamicList<double>();

            var index = list.Remove(2.532);

            Assert.AreEqual(-1, index, "The returned index is not correct.");
        }
        public void FoundingElementInListShouldNotFoundIt()
        {
            var numbers = new DynamicList<int>();

            numbers.Add(10);
            numbers.Add(12);
            numbers.Add(-14);

            var initialCount = numbers.Count;
            var index = numbers.Remove(12);

            Assert.IsFalse(numbers.Contains(12), "The element is not removed.");
            Assert.IsTrue(numbers.Count < initialCount, "The count does not decrease.");
            Assert.AreEqual(1, index, "Return invalid index.");
        }