本文整理汇总了C#中DynamicList.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicList.Remove方法的具体用法?C# DynamicList.Remove怎么用?C# DynamicList.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicList
的用法示例。
在下文中一共展示了DynamicList.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRemove_NotExistingElement_ShouldNeutralIndex
public void TestRemove_NotExistingElement_ShouldNeutralIndex()
{
var list = new DynamicList<int>();
var index = list.Remove(1);
Assert.AreEqual(-1, index);
}
示例2: TestRemoveMethod_WithNonExistingObject_ShouldReturnNegativeValue
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!");
}
示例3: Count_MultipleAddAndRemove_ShouldProperCount
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);
}
示例4: RemoveAndRemoveAtTest
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.");
}
示例5: Count_SingleAddAndRemove_ShouldProperCount
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);
}
示例6: RemovingNoneExistingElementFromNoneEmptyDynamicListOfIntsShouldReturnMinusOne
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)));
}
示例7: TestRemoveWhenListIsEmptyOrNotFound
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");
}
示例8: TestRemoveMethod_AddingAndRemovingObjects
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!");
}
示例9: TestCountAfterRemoveElementFromList
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.");
}
示例10: TestCountAfterRemoveExistingElement
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.");
}
示例11: TestRemove
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.");
}
示例12: IndexationTest
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");
}
示例13: RemoveNonExistingElement_NotSuccessful
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!");
}
示例14: RemoveElement_ElementSuccessfullyRemoved
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!");
}
示例15: RemoveExistingElement_Successful
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!");
}