Exemplo n.º 1
0
        public async ValueTask ElementAtAsync_With_ValidData_Must_Return_Some(int[] source)
        {
            var wrapped = Wrap.AsAsyncValueEnumerable(source);

            for (var index = 0; index < source.Length; index++)
            {
                // Arrange
                var expected =
                    System.Linq.Enumerable.ElementAt(source, index);

                // Act
                var result = await AsyncValueEnumerable
                             .ElementAtAsync <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int>(wrapped, index);

                // Assert
                _ = result.Match(
                    value => value.Must().BeEqualTo(expected),
                    () => throw new Exception());
            }
        }
Exemplo n.º 2
0
        public async void ElementAtAsync_With_OutOfRange_Must_Return_None(int[] source)
        {
            // Arrange
            var wrapped = Wrap.AsAsyncValueEnumerable(source);

            // Act
            var optionNegative = await AsyncValueEnumerable
                                 .ElementAtAsync <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int>(wrapped, -1);

            var optionTooLarge = await AsyncValueEnumerable
                                 .ElementAtAsync <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int>(wrapped, source.Length);

            // Assert
            _ = optionNegative.Must()
                .BeOfType <Option <int> >()
                .EvaluateTrue(option => option.IsNone);
            _ = optionTooLarge.Must()
                .BeOfType <Option <int> >()
                .EvaluateTrue(option => option.IsNone);
        }