Exemple #1
0
        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 = Enumerable
                               .ElementAt(source, index);

                // Act
                var result = ValueEnumerableExtensions
                             .ElementAt <Wrap.ValueEnumerableWrapper <int>, Wrap.Enumerator <int>, int>(wrapped, index);

                // Assert
                _ = result.Match(
                    value => value.Must().BeEqualTo(expected),
                    () => throw new Exception());
            }
        }
Exemple #2
0
        public void ElementAt_With_OutOfRange_Must_Return_None(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);

            // Act
            var optionNegative = ValueEnumerableExtensions
                                 .ElementAt <Wrap.ValueEnumerableWrapper <int>, Wrap.Enumerator <int>, int>(wrapped, -1);
            var optionTooLarge = ValueEnumerableExtensions
                                 .ElementAt <Wrap.ValueEnumerableWrapper <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);
        }