示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 public void IndexOf_NullList_ThrowsNullReferenceException()
 {
     // Arrange, Act, and Assert
     Assert.Throws <NullReferenceException>(() => IReadOnlyListExtensions.IndexOf(null, 1));
 }