Exemple #1
0
        public FatValueType Hyperlinq_Pool()
        {
            using var array = ListBindings
                              .Where(source, item => item.IsEven())
                              .Select(item => item * 2)
                              .ToArray(MemoryPool <FatValueType> .Shared);

            return(Count == 0 ? default : array.Memory.Span[0]);
        }
        public FatValueType Hyperlinq()
        {
            var sum = default(FatValueType);

            foreach (var item in ListBindings.Where(source, item => item.IsEven()).Select(item => item * 2))
            {
                sum += item;
            }
            return(sum);
        }
        public int Hyperlinq()
        {
            var sum = 0;

            foreach (var item in ListBindings.Distinct(source))
            {
                sum += item;
            }
            return(sum);
        }
        public int Hyperlinq()
        {
            var sum = 0;

            foreach (var item in ListBindings.Skip(source, Skip).Take(Count).Where(item => item.IsEven()))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #5
0
        public FatValueType Hyperlinq_Foreach()
        {
            var sum = default(FatValueType);

            foreach (var item in ListBindings.Skip(source, Skip).Take(Count).Select(item => item * 2))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #6
0
        public FatValueType Hyperlinq()
        {
            var sum = default(FatValueType);

            foreach (ref readonly var item in ListBindings.WhereRef(source, item => item.IsEven()))
            {
                sum += item;
            }
            return(sum);
        }
        public int Hyperlinq_Where()
        {
            var sum = 0;

            foreach (var item in ListBindings.Where(list, item => (item & 0x01) == 0))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #8
0
        public int Hyperlinq()
        {
            var sum = 0;

            foreach (var item in ListBindings.Where(source, item => item.IsEven()).Select(item => item * 2))
            {
                sum += item;
            }
            return(sum);
        }
        public int Hyperlinq_Foreach()
        {
            var sum = 0;

            foreach (var item in ListBindings.Skip(source, Skip).Take(Count).Select(item => item * 2))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #10
0
        public FatValueType Hyperlinq()
        {
            var sum = default(FatValueType);

            foreach (var item in ListBindings.Skip(source, Skip).Take(Count).Where(item => item.IsEven()))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #11
0
        public int Hyperlinq_Foreach()
        {
            var sum = 0;

            foreach (var item in ListBindings.Select(source, item => item * 2))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #12
0
        public FatValueType Hyperlinq()
        {
            var sum = default(FatValueType);

            foreach (var item in ListBindings.Distinct(source))
            {
                sum += item;
            }
            return(sum);
        }
Exemple #13
0
        public int Hyperlinq_For()
        {
            var items = ListBindings.Select(source, item => item * 2);
            var sum   = 0;

            for (var index = 0; index < items.Count; index++)
            {
                sum += items[index];
            }
            return(sum);
        }
Exemple #14
0
        public FatValueType Hyperlinq_For()
        {
            var sum   = default(FatValueType);
            var items = ListBindings.Skip(source, Skip).Take(Count).Select(item => item * 2);

            for (var index = 0; index < items.Count; index++)
            {
                sum += items[index];
            }
            return(sum);
        }
Exemple #15
0
        public void AsEnumerable_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var list = source.ToList();

            // Act
            var result = ListBindings
                         .AsEnumerable(list);

            // Assert
            _ = result.Must()
                .BeSameAs(list);
        }
Exemple #16
0
        public void Single_With_Empty_Must_Return_None(int[] source)
        {
            // Arrange
            var list = source.ToList();

            // Act
            var result = ListBindings
                         .Single(list);

            // Assert
            _ = result.Must()
                .BeOfType <Option <int> >()
                .EvaluateTrue(option => option.IsNone);
        }
Exemple #17
0
        public void Contains_With_Null_And_Contains_Must_ReturnTrue(int[] source)
        {
            // Arrange
            var list  = source.ToList();
            var value = source.Last();

            // Act
            var result = ListBindings
                         .Contains(list, value);

            // Assert
            _ = result.Must()
                .BeTrue();
        }
Exemple #18
0
        public void ToList_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var list = source.ToList();

            // Act
            var result = ListBindings
                         .ToArray(list);

            // Assert
            _ = result.Must()
                .BeEnumerableOf <int>()
                .BeEqualTo(source);
        }
Exemple #19
0
        public void Contains_With_Null_And_NotContains_Must_ReturnFalse(int[] source)
        {
            // Arrange
            var list  = source.ToList();
            var value = int.MaxValue;

            // Act
            var result = ListBindings
                         .Contains(list, value);

            // Assert
            _ = result.Must()
                .BeFalse();
        }
Exemple #20
0
        public void AsValueEnumerable_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var list = source.ToList();

            // Act
            var result = ListBindings
                         .AsValueEnumerable(list);

            // Assert
            _ = result.Must()
                .BeAssignableTo <IValueReadOnlyList <int, List <int> .Enumerator> >()
                .BeEnumerableOf <int>()
                .BeEqualTo(source);
        }
Exemple #21
0
        public void Count_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .Count(source);

            // Act
            var result = ListBindings
                         .Count(list);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
        public void Skip_With_ValidData_Must_Succeed(int[] source, int count)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .Skip(source, count);

            // Act
            var result = ListBindings
                         .Skip(list, count);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Exemple #23
0
        public void All_Predicate_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .All(source, predicate.AsFunc());

            // Act
            var result = ListBindings
                         .All(list, predicate);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Exemple #24
0
        public void Single_With_Single_Must_Return_Some(int[] source)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .Single(source);

            // Act
            var result = ListBindings
                         .Single(list);

            // Assert
            _ = result.Match(
                value => value.Must().BeEqualTo(expected),
                () => throw new Exception());
        }
Exemple #25
0
        public void ToDictionary_KeySelector_ElementSelector_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .ToDictionary(source, item => item, item => item);

            // Act
            var result = ListBindings
                         .ToDictionary(list, item => item, item => item);

            // Assert
            _ = result.Must()
                .BeEnumerableOf <KeyValuePair <int, int> >()
                .BeEqualTo(expected, testNonGeneric: false);
        }
Exemple #26
0
        public void ElementAt_With_ValidData_Must_Return_Some(int[] source)
        {
            // Arrange
            var list = source.ToList();

            for (var index = 0; index < source.Length; index++)
            {
                // Act
                var result = ListBindings
                             .ElementAt(list, index);

                // Assert
                _ = result.Match(
                    value => value.Must().BeEqualTo(source[index]),
                    () => throw new Exception());
            }
        }
Exemple #27
0
        public void Select_SelectorAt_With_ValidData_Must_Succeed(int[] source, NullableSelectorAt <int, string> selector)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .Select(source, selector.AsFunc());

            // Act
            var result = ListBindings
                         .Select(list, selector);

            // Assert
            _ = result.Must()
                .BeEnumerableOf <string>()
                .BeEqualTo(expected, testRefStructs: false);
            _ = result.SequenceEqual(expected).Must().BeTrue();
        }
Exemple #28
0
        public void Where_PredicateAt_With_ValidData_Must_Succeed(int[] source, PredicateAt <int> predicate)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .Where(source, predicate.AsFunc());

            // Act
            var result = ListBindings
                         .Where(list, predicate);

            // Assert
            _ = result.Must()
                .BeEnumerableOf <int>()
                .BeEqualTo(expected, testRefStructs: false);
            _ = result.SequenceEqual(expected).Must().BeTrue();
        }
Exemple #29
0
        public void Distinct_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var list     = source.ToList();
            var expected = Enumerable
                           .Distinct(source);

            // Act
            var result = ListBindings
                         .Distinct(list);

            // Assert
            _ = result.Must()
                .BeEnumerableOf <int>()
                .BeEqualTo(expected, testRefStructs: false, testRefReturns: false);
            _ = result.SequenceEqual(expected).Must().BeTrue();
        }
Exemple #30
0
        public void ElementAt_With_OutOfRange_Must_Return_None(int[] source)
        {
            // Arrange
            var list = source.ToList();

            // Act
            var optionTooSmall = ListBindings
                                 .ElementAt(list, -1);
            var optionTooLarge = ListBindings
                                 .ElementAt(list, source.Length);

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