当前位置: 首页>>代码示例>>C#>>正文


C# DynamicList.IndexOf方法代码示例

本文整理汇总了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.");
        }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:13,代码来源:DynamicListTests.cs

示例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);
 }
开发者ID:pavelilchev,项目名称:HomeWorks,代码行数:7,代码来源:TestDynamicListIndexOfAndContains.cs

示例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.");
 }
开发者ID:bnaskov,项目名称:SoftUni,代码行数:8,代码来源:DynamicListsTests.cs

示例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)));
        }
开发者ID:borko9696,项目名称:SoftwareUniversity,代码行数:9,代码来源:UnitTest.cs

示例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);
        }
开发者ID:alex687,项目名称:SoftUni-Homeworks,代码行数:10,代码来源:DynamicListTest.cs

示例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");
        }
开发者ID:zhecho1215,项目名称:Softuni,代码行数:12,代码来源:DynamicListTests.cs

示例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);
        }
开发者ID:msmilkoff,项目名称:HighQualityCodeHomeworks,代码行数:12,代码来源:UnitTest1.cs

示例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!");
        }
开发者ID:i-yotov,项目名称:Courses,代码行数:13,代码来源:DynamicListTests.cs

示例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.");
        }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:17,代码来源:DynamicListTests.cs

示例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.");
        }
开发者ID:ivayloivanof,项目名称:HQC,代码行数:10,代码来源:DynamicListTest.cs

示例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.");
        }
开发者ID:AsenTahchiyski,项目名称:SoftUni,代码行数:12,代码来源:LinkedListTests.cs

示例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.");
        }
开发者ID:borko9696,项目名称:SoftwareUniversity,代码行数:12,代码来源:UnitTest.cs

示例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!");
        }
开发者ID:dhristoskov,项目名称:HighQualityCode,代码行数:10,代码来源:LinkedListTests.cs

示例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.");
        }
开发者ID:hristodobrev,项目名称:Software-University,代码行数:12,代码来源:DynamicListTest.cs

示例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");
        }
开发者ID:KostaDinkov,项目名称:SoftUni,代码行数:21,代码来源:DynamicListTests.cs


注:本文中的DynamicList.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。