コード例 #1
0
        public void Distinct_With_ValidData_Must_Succeed(int[] source, int skip, int take)
        {
            // Arrange
            var(offset, count) = Utils.SkipTake(source.Length, skip, take);
            var wrapped  = new ArraySegment <int>(source, offset, count);
            var expected = wrapped
                           .Distinct();

            // Act
            var result = wrapped.AsValueEnumerable()
                         .Distinct();

            // Assert
            _ = result.Must()
                .BeEnumerableOf <int>()
                .BeEqualTo(expected, testRefStructs: false, testRefReturns: false);
            _ = result.SequenceEqual(expected).Must().BeTrue();
        }
コード例 #2
0
        public void Distinct_Sum_With_ValidData_Must_Succeed(int[] source, int skip, int take)
        {
            // Arrange
            var(offset, count) = Utils.SkipTake(source.Length, skip, take);
            var wrapped  = new ArraySegment <int>(source, offset, count);
            var expected = wrapped
                           .Distinct()
                           .Sum();

            // Act
            var result = wrapped.AsValueEnumerable()
                         .Distinct()
                         .Sum();

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
コード例 #3
0
        public void Distinct_ToArray_MemoryPool_With_ValidData_Must_Succeed(int[] source, int skip, int take)
        {
            // Arrange
            var pool = ArrayPool <int> .Shared;

            var(offset, count) = Utils.SkipTake(source.Length, skip, take);
            var wrapped  = new ArraySegment <int>(source, offset, count);
            var expected = wrapped
                           .Distinct()
                           .ToArray();

            // Act
            using var result = wrapped.AsValueEnumerable()
                               .Distinct()
                               .ToArray(pool);

            // Assert
            _ = result
                .SequenceEqual(expected);
        }