public void List_ElementAt() { var list = new int[] { 3 }; Assert.AreEqual(3, ReadOnlyList.ElementAt(list, 0)); list = new int[] { 9, 3, 1 }; Assert.AreEqual(3, ReadOnlyList.ElementAt(list, 1)); }
public void ElementAt_With_OutOfRange_Must_Throw(int[] source, int index) { // Arrange var wrapped = Wrap .AsValueReadOnlyList(source); // Act Action action = () => _ = ReadOnlyList .ElementAt <Wrap.ValueReadOnlyList <int>, int>(wrapped, index); // Assert _ = action.Must() .Throw <ArgumentOutOfRangeException>(); }
public void ElementAt_With_ValidData_Must_Succeed(int[] source, int index) { // Arrange var wrapped = Wrap .AsValueReadOnlyList(source); var expected = System.Linq.Enumerable.ElementAt(wrapped, index); // Act var result = ReadOnlyList .ElementAt <Wrap.ValueReadOnlyList <int>, int>(wrapped, index); // Assert _ = result.Must() .BeEqualTo(expected); }
public void ElementAt_With_ValidData_Must_Return_Some(int[] source) { for (var index = 0; index < source.Length; index++) { // Arrange var wrapped = Wrap.AsValueReadOnlyList(source); var expected = System.Linq.Enumerable.ElementAt(source, index); // Act var result = ReadOnlyList .ElementAt <Wrap.ValueReadOnlyList <int>, int>(wrapped, index); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); } }
public void ElementAt_With_OutOfRange_Must_Return_None(int[] source) { // Arrange var wrapped = Wrap.AsValueReadOnlyList(source); // Act var optionNegative = ReadOnlyList .ElementAt <Wrap.ValueReadOnlyList <int>, int>(wrapped, -1); var optionTooLarge = ReadOnlyList .ElementAt <Wrap.ValueReadOnlyList <int>, int>(wrapped, source.Length); // Assert _ = optionNegative.Must() .BeOfType <Option <int> >() .EvaluateTrue(option => option.IsNone); _ = optionTooLarge.Must() .BeOfType <Option <int> >() .EvaluateTrue(option => option.IsNone); }