public void ElementAt() { // Basis for some assertions that follow Assert.Throws <IndexOutOfRangeException>(() => Enumerable.ElementAt(empty, 0)); Assert.Throws <IndexOutOfRangeException>(() => Enumerable.ElementAt(manyElements, -1)); Assert.Throws <NullReferenceException>(() => ImmutableArrayExtensions.ElementAt(emptyDefault, 0)); Assert.Throws <IndexOutOfRangeException>(() => ImmutableArrayExtensions.ElementAt(empty, 0)); Assert.Throws <IndexOutOfRangeException>(() => ImmutableArrayExtensions.ElementAt(manyElements, -1)); Assert.Equal(1, ImmutableArrayExtensions.ElementAt(oneElement, 0)); Assert.Equal(3, ImmutableArrayExtensions.ElementAt(manyElements, 2)); }
public void ElementAt() { // Basis for some assertions that follow Assert.Throws <IndexOutOfRangeException>(() => Enumerable.ElementAt(s_empty, 0)); #if NET35PLUS // .NET Framework Assert.Throws <IndexOutOfRangeException>(() => Enumerable.ElementAt(s_manyElements, -1)); #else // LinqBridge Assert.Throws <ArgumentOutOfRangeException>(() => Enumerable.ElementAt(s_manyElements, -1)); #endif Assert.Throws <NullReferenceException>(() => ImmutableArrayExtensions.ElementAt(s_emptyDefault, 0)); Assert.Throws <IndexOutOfRangeException>(() => ImmutableArrayExtensions.ElementAt(s_empty, 0)); Assert.Throws <IndexOutOfRangeException>(() => ImmutableArrayExtensions.ElementAt(s_manyElements, -1)); Assert.Equal(1, ImmutableArrayExtensions.ElementAt(s_oneElement, 0)); Assert.Equal(3, ImmutableArrayExtensions.ElementAt(s_manyElements, 2)); }