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(); }
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); }
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); }