System.Collections.Tests.IList_NonGeneric_Tests.IList_NonGeneric_IndexOf_ReturnsFirstMatchingValue C# (CSharp) Method

IList_NonGeneric_IndexOf_ReturnsFirstMatchingValue() private method

private IList_NonGeneric_IndexOf_ReturnsFirstMatchingValue ( int count ) : void
count int
return void
        public void IList_NonGeneric_IndexOf_ReturnsFirstMatchingValue(int count)
        {
            if (!IsReadOnly && !ExpectedFixedSize)
            {
                IList list = NonGenericIListFactory(count);

                object[] arr = new object[count];
                list.CopyTo(arr, 0);

                foreach (object duplicate in arr) // hard copies list to circumvent enumeration error
                    list.Add(duplicate);
                object[] expected = new object[count * 2];
                list.CopyTo(expected, 0);

                Assert.All(Enumerable.Range(0, count), (index =>
                    Assert.Equal(index, list.IndexOf(expected[index]))
                ));
            }
        }
IList_NonGeneric_Tests