public void IndexOf_ValueNotInList_CorrectlyReturnsNegativeOne() { // Arrange IReadOnlyList <int> list = new[] { 2, 4, 6, 8 }; // Act int index = IReadOnlyListExtensions.IndexOf(list, 1); // Assert Assert.Equal(-1, index); }
public void IndexOf_ValueAppearsMultipleTimes_CorrectlyReturnsFirstInstance() { // Arrange IReadOnlyList <int> list = new[] { 2, 4, 6, 8, 4 }; // Act int index = IReadOnlyListExtensions.IndexOf(list, 4); // Assert Assert.Equal(1, index); }
public void IndexOf_ValueInList_CorrectlyReturnsIndex() { // Arrange IReadOnlyList <int> list = new[] { 6, 4, 1, 8 }; // Act int index = IReadOnlyListExtensions.IndexOf(list, 1); // Assert Assert.Equal(2, index); }
public void IndexOf_NullList_ThrowsNullReferenceException() { // Arrange, Act, and Assert Assert.Throws <NullReferenceException>(() => IReadOnlyListExtensions.IndexOf(null, 1)); }