public void ElementAt_With_OutOfRange_Must_Throw(int[] source, int index) { // Arrange var wrapped = Wrap .AsValueEnumerable(source); // Act Action action = () => _ = ValueEnumerable .ElementAt <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped, index); // Assert _ = action.Must() .Throw <ArgumentOutOfRangeException>(); }
public void ElementAt_With_ValidData_Must_Succeed(int[] source, int index) { // Arrange var wrapped = Wrap .AsValueEnumerable(source); var expected = System.Linq.Enumerable.ElementAt(wrapped, index); // Act var result = ValueEnumerable .ElementAt <Wrap.ValueEnumerable <int>, Wrap.Enumerator <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.AsValueEnumerable(source); var expected = System.Linq.Enumerable.ElementAt(source, index); // Act var result = ValueEnumerable .ElementAt <Wrap.ValueEnumerable <int>, Wrap.Enumerator <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.AsValueEnumerable(source); // Act var optionNegative = ValueEnumerable .ElementAt <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped, -1); var optionTooLarge = ValueEnumerable .ElementAt <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped, source.Length); // Assert _ = optionNegative.Must() .BeOfType <Option <int> >() .EvaluateTrue(option => option.IsNone); _ = optionTooLarge.Must() .BeOfType <Option <int> >() .EvaluateTrue(option => option.IsNone); }