public void FindIndexBadArguments() { Assert.Throws <ArgumentNullException>(delegate { ListUtility.FindIndex <object>(null, n => true); }); Assert.Throws <ArgumentNullException>(delegate { ListUtility.FindIndex(new object[] { }, null); }); }
public void FindIndex() { Assert.AreEqual(-1, ListUtility.FindIndex(new object[] { }, n => true)); Assert.AreEqual(0, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, n => n < 5)); Assert.AreEqual(5, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, n => n > 5)); Assert.AreEqual(5, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 5, n => n > 5)); Assert.AreEqual(6, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 6, n => n > 5)); Assert.AreEqual(-1, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 6, n => n == 5)); Assert.AreEqual(9, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, n => n == 10)); Assert.AreEqual(-1, ListUtility.FindIndex(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, n => n == 11)); }