public void ElementAt_With_ValidData_Must_Return_Some(int[] source) { for (var index = 0; index < source.Length; index++) { // Arrange var wrapped = Wrap .AsValueReadOnlyCollection(source); var expected = Enumerable .ElementAt(source, index); // Act var result = ValueReadOnlyCollectionExtensions .ElementAt <Wrap.ValueReadOnlyCollectionWrapper <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 .AsValueReadOnlyCollection(source); // Act var optionNegative = ValueReadOnlyCollectionExtensions .ElementAt <Wrap.ValueReadOnlyCollectionWrapper <int>, Wrap.Enumerator <int>, int>(wrapped, -1); var optionTooLarge = ValueReadOnlyCollectionExtensions .ElementAt <Wrap.ValueReadOnlyCollectionWrapper <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); }