本文整理汇总了C#中DynamicList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicList.Add方法的具体用法?C# DynamicList.Add怎么用?C# DynamicList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicList
的用法示例。
在下文中一共展示了DynamicList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCountAfterAddTwoElementsToList
public void TestCountAfterAddTwoElementsToList()
{
DynamicList<int> list = new DynamicList<int>();
list.Add(1);
list.Add(2);
int count = list.Count;
Assert.AreEqual(2, count, "List count should be 2 after adding two elements.");
}
示例2: TestAddingNodeOnNonExistingPositivePositionMustThrowArgumentOutOfRangeException
public void TestAddingNodeOnNonExistingPositivePositionMustThrowArgumentOutOfRangeException()
{
var list = new DynamicList<int>();
list.Add(1);
list.Add(1);
list.Add(1);
list[3] = 3;
}
示例3: ChangeValueOfGivenPositionShoudChangeTheValueAtThisPosition
public void ChangeValueOfGivenPositionShoudChangeTheValueAtThisPosition()
{
var numList = new DynamicList<int>();
numList.Add(2);
numList.Add(-10);
numList[0] = 9;
Assert.AreEqual(numList[0], 9, "The value is not equal to the expected change.");
}
示例4: RemoveShouldThrowExceptionIfIndexIsNotPresent
public void RemoveShouldThrowExceptionIfIndexIsNotPresent()
{
DynamicList<int> list = new DynamicList<int>();
list.Add(2);
list.Add(3);
list.Add(4);
list.RemoveAt(4);
}
示例5: ListElementsCheckingElementNotInTheListShoudNotContainElement
public void ListElementsCheckingElementNotInTheListShoudNotContainElement()
{
var list = new DynamicList<int>();
list.Add(1);
list.Add(2);
Assert.IsFalse(list.Contains(6), "The list must not contain 6.");
}
示例6: GetElementWithIncorrectIndexShoudThrowArgumentNullException
public void GetElementWithIncorrectIndexShoudThrowArgumentNullException()
{
var list = new DynamicList<int>();
list.Add(2);
list.Add(6);
int element = list[2];
}
示例7: FoundingElementInListShouldReturnIndexOfElement
public void FoundingElementInListShouldReturnIndexOfElement()
{
var numList = new DynamicList<int>();
numList.Add(13);
numList.Add(-6);
int index = numList.IndexOf(-6);
Assert.AreEqual(1, index, "Invalid index.");
}
示例8: TestCountAfterTwoElementsAdded
public void TestCountAfterTwoElementsAdded()
{
var list = new DynamicList<int>();
list.Add(1);
list.Add(2);
var count = list.Count;
Assert.AreEqual(2, count, "List count should be 2 after adding two elements.");
}
示例9: Test_IndexGetReturnsThirdElementOneHundread
public void Test_IndexGetReturnsThirdElementOneHundread()
{
var dynList = new DynamicList<int>();
dynList.Add(10);
dynList.Add(50);
dynList.Add(100);
Assert.AreEqual(100, dynList[2], "Index do not returns the correct value of an element at specified index.");
}
示例10: AddingMoreElementsShouldIncreaseTheElemetsCount
public void AddingMoreElementsShouldIncreaseTheElemetsCount()
{
var numList = new DynamicList<int>();
numList.Add(2);
numList.Add(-10);
numList.Add(5);
Assert.AreEqual(3, numList.Count, "The list count is not equal to the number of added elements.");
}
示例11: TestRemoveAt_ValidIndex_ShouldReturnProperElement
public void TestRemoveAt_ValidIndex_ShouldReturnProperElement()
{
var list = new DynamicList<int>();
list.Add(5);
list.Add(15);
var element = list.RemoveAt(1);
Assert.AreEqual(15, element);
}
示例12: 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!");
}
示例13: SettingElementAtOutOfRangePositionInNoneEmptyDynamicListOfIntsShouldThrowException
public void SettingElementAtOutOfRangePositionInNoneEmptyDynamicListOfIntsShouldThrowException()
{
var dynamicListOfInts = new DynamicList<int>();
dynamicListOfInts.Add(1);
dynamicListOfInts.Add(2);
dynamicListOfInts.Add(3);
dynamicListOfInts[4] = 4;
}
示例14: RemovingElementAtOutOfRangePositionFromNoneEmptyDynamicListOfIntsShouldThrowException
public void RemovingElementAtOutOfRangePositionFromNoneEmptyDynamicListOfIntsShouldThrowException()
{
var dynamicListOfInts = new DynamicList<int>();
dynamicListOfInts.Add(1);
dynamicListOfInts.Add(2);
dynamicListOfInts.Add(3);
dynamicListOfInts.RemoveAt(4);
}
示例15: TestCountAfterRemoveNonExistingElementFromList
public void TestCountAfterRemoveNonExistingElementFromList()
{
DynamicList<string> list = new DynamicList<string>();
list.Add("one");
list.Add("two");
int count = list.Count;
Assert.AreEqual(2, count, "The count of the list should remain unchanged after trying to remove a non-existing element.");
}