本文整理汇总了C#中DynamicList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicList.IndexOf方法的具体用法?C# DynamicList.IndexOf怎么用?C# DynamicList.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicList
的用法示例。
在下文中一共展示了DynamicList.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddContainsAndIndexOfTest
public void AddContainsAndIndexOfTest()
{
DynamicList<string> words = new DynamicList<string>();
words.Add("Pesho");
words.Add("Strahil");
Assert.AreEqual(2, words.Count, "Error in the adding command.");
Assert.IsFalse(words.Contains("Ivan"), "Contains method works incorectly.");
Assert.IsTrue(words.Contains("Pesho"), "Error in adding or contains.");
Assert.AreEqual(-1, words.IndexOf("Ivan"), "Error in indexOf method.");
Assert.AreNotEqual(-1, words.IndexOf("Strahil"), "Error in indexOf method.");
}
示例2: TestIndexOf_ExistingElement_ShouldReturnProperIndex
public void TestIndexOf_ExistingElement_ShouldReturnProperIndex()
{
var list = new DynamicList<int>();
list.Add(5);
var index = list.IndexOf(5);
Assert.AreEqual(0, index);
}
示例3: 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.");
}
示例4: GettingIndexOfNoneExistingElementFromNoneEmptyDynamicListOfIntsShouldReturnMinusOne
public void GettingIndexOfNoneExistingElementFromNoneEmptyDynamicListOfIntsShouldReturnMinusOne()
{
var dynamicListOfInts = new DynamicList<int>();
dynamicListOfInts.Add(1);
var returnedValue = dynamicListOfInts.IndexOf(9);
Assert.AreEqual(-1, returnedValue, string.Format("The method \"IndexOf\" does not work correctly when tring to get none existing number." + string.Format("\nShould return -1 it returns {0}!", returnedValue)));
}
示例5: IndexOfElementShoudReturnCorrenctIndex
public void IndexOfElementShoudReturnCorrenctIndex()
{
var list = new DynamicList<int>();
list.Add(2);
list.Add(6);
int index = list.IndexOf(6);
Assert.AreEqual(1, index, "The returned index is not correct must be 1 instead its " + index);
}
示例6: IndexOfTest
public void IndexOfTest()
{
DynamicList<int> list = new DynamicList<int>();
list.Add(1);
list.Add(2);
list.Add(3);
var result = list.IndexOf(3);
Assert.AreEqual(2, result, "Index of does not search the list correctly");
}
示例7: IndexOf_GetIndexOf_ShouldReturnIndexOfSelectedItem
public void IndexOf_GetIndexOf_ShouldReturnIndexOfSelectedItem()
{
var list = new DynamicList<int>();
list.Add(1);
list.Add(2);
list.Add(3);
var expected = 0;
var actual = list.IndexOf(1);
Assert.AreEqual(expected, actual);
}
示例8: GetIndexOfExistingElement_ReturnElementIndex
public void GetIndexOfExistingElement_ReturnElementIndex()
{
var dynamicList = new DynamicList<int>();
const int firstElement = 666;
const int secondElement = 777;
dynamicList.Add(firstElement);
dynamicList.Add(secondElement);
var index = dynamicList.IndexOf(secondElement);
Assert.AreEqual(1, index, "The element's index should be 1!");
}
示例9: 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.");
}
示例10: TestIndexOfForIsEmptyList
public void TestIndexOfForIsEmptyList()
{
var dynamicList = new DynamicList<int>();
// Act
var returnetIndex = dynamicList.IndexOf(0);
// Assert
Assert.IsTrue(returnetIndex < 0, "This list is not empty.");
}
示例11: TestIndexOf_TryingToGetIndexOfMissingElementShouldReturnMinus1
public void TestIndexOf_TryingToGetIndexOfMissingElementShouldReturnMinus1()
{
// Arrange
DynamicList<int> testList = new DynamicList<int>();
// Act
FillTestListWith10Elements(testList);
int test = testList.IndexOf(10);
// Assert
Debug.Assert(test == -1, "Trying to get the index of non-existent element should return -1.");
}
示例12: RemovingElementAtIndexShouldRemoveElementOfList
public void RemovingElementAtIndexShouldRemoveElementOfList()
{
var numbers = new DynamicList<int>();
numbers.Add(15);
numbers.Add(10);
var number = numbers.RemoveAt(0);
var result = numbers.IndexOf(0);
Assert.AreEqual(-1, result, "The elements is founded.");
Assert.AreEqual(10, numbers[0], "Do not reorders the elements.");
}
示例13: Test_DynamicListIndexOf_ShouldReturnIndex
public void Test_DynamicListIndexOf_ShouldReturnIndex()
{
DynamicList<string> testList = new DynamicList<string>();
string item = "dynamic";
testList.Add(item);
int actual = testList.IndexOf(item);
Assert.AreEqual(0, actual, "Did not return zero for finding the item in the list!");
}
示例14: IndexOf_FromAlreadyInitializedList_ShouldReturnTheFirstOccurencyIndexOfTheItem
public void IndexOf_FromAlreadyInitializedList_ShouldReturnTheFirstOccurencyIndexOfTheItem()
{
var list = new DynamicList<double>();
list.Add(5.32);
list.Add(2.532);
list.Add(3.21);
list.Add(2.523);
var index = list.IndexOf(2.532);
Assert.AreEqual(1, index, "The returned index is not correct.");
}
示例15: IndexOfTest
public void IndexOfTest()
{
//Case with Integer
list.Add(5);
list.Add(1);
list.Add(4);
var case1 = list.IndexOf(4);
Assert.AreEqual(2, case1, "Wrong results with integer data type");
//Case with String
var listString = new DynamicList<string>();
listString.Add("Hello");
listString.Add("Software");
listString.Add("University");
var case2 = listString.IndexOf("Software");
Assert.AreEqual(1, case2, "Wrong results with string data type");
}