public void Select_SourceIsArray_First() { var source = new[] { 1, 2, 3, 4 }.Select(i => i * 2); Assert.Equal(2, source.First()); Assert.Equal(2, source.FirstOrDefault()); Assert.Equal(6, source.Skip(2).First()); Assert.Equal(6, source.Skip(2).FirstOrDefault()); Assert.Throws<InvalidOperationException>(() => source.Skip(4).First()); Assert.Throws<InvalidOperationException>(() => source.Skip(14).First()); Assert.Equal(0, source.Skip(4).FirstOrDefault()); Assert.Equal(0, source.Skip(14).FirstOrDefault()); var empty = new int[0].Select(i => i * 2); Assert.Throws<InvalidOperationException>(() => empty.First()); Assert.Equal(0, empty.FirstOrDefault()); }