Exemplo n.º 1
0
        public void All_Predicate_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate)
        {
            // Arrange
            var expected = System.Linq.Enumerable.All(source, predicate.AsFunc());

            // Act
            var result = ArrayExtensions
                         .All <int>(source.AsSpan(), predicate);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
        public void All_With_NullArray_Must_Succeed()
        {
            // Arrange
            var source = default(ArraySegment <int>);

            // Act
            var result = ArrayExtensions
                         .All(source, _ => true);

            // Assert
            _ = result.Must()
                .BeTrue();
        }
Exemplo n.º 3
0
        public void All_Predicate_With_NullPredicate_Must_Throw()
        {
            // Arrange
            var source    = new int[0];
            var predicate = (Predicate <int>)null;

            // Act
            Action action = () => _ = ArrayExtensions
                                      .All <int>(source.AsSpan(), predicate);

            // Assert
            _ = action.Must()
                .Throw <ArgumentNullException>()
                .EvaluateTrue(exception => exception.ParamName == "predicate");
        }
Exemplo n.º 4
0
        public void All_PredicateAt_With_ValidData_Must_Succeed(int[] source, PredicateAt <int> predicate)
        {
            // Arrange
            var expected =
                System.Linq.Enumerable.Count(
                    System.Linq.Enumerable.Where(source, predicate.AsFunc())) == source.Length;

            // Act
            var result = ArrayExtensions
                         .All <int>((ReadOnlyMemory <int>)source.AsMemory(), predicate);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Exemplo n.º 5
0
        public void All_PredicateAt_With_ValidData_Must_Succeed(int[] source, PredicateAt <int> predicate)
        {
            // Arrange
            var expected = Enumerable
                           .Where(source, predicate.AsFunc())
                           .Count() == source.Length;

            // Act
            var result = ArrayExtensions
                         .All(source, predicate);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Exemplo n.º 6
0
        public void All_PredicateAt_With_ValidData_Must_Succeed(int[] source, Func <int, int, bool> predicate)
        {
            // Arrange
            var expected =
                System.Linq.Enumerable.Count(
                    System.Linq.Enumerable.Where(source, predicate)) == source.Length;

            // Act
            var result = ArrayExtensions
                         .All <int>(source.AsSpan(), predicate);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
        public void All_Predicate_With_ValidData_Must_Succeed(int[] source, int skip, int take, Func <int, bool> predicate)
        {
            // Arrange
            var(offset, count) = Utils.SkipTake(source.Length, skip, take);
            var wrapped  = new ArraySegment <int>(source, offset, count);
            var expected = Enumerable
                           .All(wrapped, predicate);

            // Act
            var result = ArrayExtensions
                         .All(wrapped, predicate);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }