public void AsValueEnumerable1_With_ValidData_Must_Succeed(int[] source) { // Arrange var wrapped = new ArraySegment <int>(source); // Act var result = wrapped .AsValueEnumerable(); // Assert _ = result.Must() .BeEnumerableOf <int>() .BeEqualTo(source, testRefStructs: false); result.SequenceEqual(source).Must().BeTrue(); }
public void Select_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 .Select((item, _) => item) .Sum(); // Act var result = wrapped.AsValueEnumerable() .Select((item, _) => item) .Sum(); // Assert _ = result.Must() .BeEqualTo(expected); }
public void Select_With_ValidData_Must_Succeed(int[] source, int skip, int take, Func <int, int, string> selector) { // Arrange var(offset, count) = Utils.SkipTake(source.Length, skip, take); var wrapped = new ArraySegment <int>(source, offset, count); var expected = wrapped .Select(selector); // Act var result = wrapped.AsValueEnumerable() .Select(selector); // Assert _ = result.Must() .BeEnumerableOf <string>() .BeEqualTo(expected, testRefStructs: false); _ = result.SequenceEqual(expected).Must().BeTrue(); }
public void Where_Sum_With_ValidData_Must_Succeed(int[] source, int skip, int take, Func <int, int, bool> predicate) { // Arrange var(offset, count) = Utils.SkipTake(source.Length, skip, take); var wrapped = new ArraySegment <int>(source, offset, count); var expected = Enumerable .Where(wrapped, predicate) .Sum(); // Act var result = wrapped.AsValueEnumerable() .Where(predicate) .Sum(); // Assert _ = result.Must() .BeEqualTo(expected); }
public void Where_With_ValidData_Must_Succeed(int[] source, int skip, int take, Func <int, int, bool> predicate) { // Arrange var(offset, count) = Utils.SkipTake(source.Length, skip, take); var wrapped = new ArraySegment <int>(source, offset, count); var expected = Enumerable .Where(wrapped, predicate); // Act var result = wrapped.AsValueEnumerable() .Where(predicate); // Assert _ = result.Must() .BeEnumerableOf <int>() .BeEqualTo(expected, testRefStructs: false, testRefReturns: false); _ = result.SequenceEqual(expected).Must().BeTrue(); }
public void AsValueEnumerable1_Count_With_ValidData_Must_Succeed(int[] source, int skipCount, int takeCount) { // Arrange var wrapped = new ArraySegment <int>(source); var expected = source .Skip(skipCount) .Take(takeCount) .Count(); // Act var result = wrapped.AsValueEnumerable() .Skip(skipCount) .Take(takeCount) .Count(); // 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); }
public void AsValueEnumerable1_Take_Take_With_ValidData_Must_Succeed(int[] source, int count0, int count1) { // Arrange var wrapped = new ArraySegment <int>(source); var expected = source .Take(count0) .Take(count1); // Act var result = wrapped .AsValueEnumerable() .Take(count0) .Take(count1); // Assert _ = result.Must() .BeEnumerableOf <int>() .BeEqualTo(expected, testRefStructs: false); result.SequenceEqual(expected).Must().BeTrue(); }