-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve coverage * Fix build
- Loading branch information
Showing
29 changed files
with
904 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
NetFabric.Hyperlinq.UnitTests/Aggregation/Sum/SumAsync.AsyncValueEnumerable.Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using NetFabric.Assertive; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace NetFabric.Hyperlinq.UnitTests.Aggregation.Sum | ||
{ | ||
public class AsyncValueEnumerableTests | ||
{ | ||
[Theory] | ||
[MemberData(nameof(TestData.Sum), MemberType = typeof(TestData))] | ||
public async ValueTask SumAsync_With_ValidData_Must_Succeed(int[] source) | ||
{ | ||
// Arrange | ||
var wrapped = Wrap.AsAsyncValueEnumerable(source); | ||
var expected = source | ||
.Sum(); | ||
|
||
// Act | ||
var result = await wrapped | ||
.SumAsync<Wrap.AsyncValueEnumerableWrapper<int>, Wrap.AsyncEnumerator<int>, int, int>() | ||
.ConfigureAwait(false); | ||
|
||
// Assert | ||
_ = result.Must() | ||
.BeEqualTo(expected); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData.NullableSum), MemberType = typeof(TestData))] | ||
public async ValueTask SumAsync_With_Nullable_ValidData_Must_Succeed(int?[] source) | ||
{ | ||
// Arrange | ||
var wrapped = Wrap.AsAsyncValueEnumerable(source); | ||
var expected = source | ||
.Sum(); | ||
|
||
// Act | ||
var result = await wrapped | ||
.SumAsync<Wrap.AsyncValueEnumerableWrapper<int?>, Wrap.AsyncEnumerator<int?>, int?, int>() | ||
.ConfigureAwait(false); | ||
|
||
// Assert | ||
_ = result.Must() | ||
.BeEqualTo(expected.Value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
NetFabric.Hyperlinq.UnitTests/Conversion/AsValueEnumerable/AsValueEnumerable.ArraySegment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
using System.Linq; | ||
using NetFabric.Assertive; | ||
using System; | ||
using Xunit; | ||
|
||
namespace NetFabric.Hyperlinq.UnitTests.Conversion.AsValueEnumerable | ||
{ | ||
public partial class ArraySegmentTests | ||
{ | ||
[Theory] | ||
[MemberData(nameof(TestData.Empty), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.Single), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.Multiple), MemberType = typeof(TestData))] | ||
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(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData.SkipEmpty), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.SkipSingle), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.SkipMultiple), MemberType = typeof(TestData))] | ||
public void AsValueEnumerable1_Skip_With_ValidData_Must_Succeed(int[] source, int count) | ||
{ | ||
// Arrange | ||
var wrapped = new ArraySegment<int>(source); | ||
var expected = source | ||
.Skip(count); | ||
|
||
// Act | ||
var result = wrapped | ||
.AsValueEnumerable() | ||
.Skip(count); | ||
|
||
// Assert | ||
_ = result.Must() | ||
.BeEnumerableOf<int>() | ||
.BeEqualTo(expected, testRefStructs: false); | ||
result.SequenceEqual(expected).Must().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData.Skip_Skip), MemberType = typeof(TestData))] | ||
public void AsValueEnumerable1_Skip_Skip_With_ValidData_Must_Succeed(int[] source, int count0, int count1) | ||
{ | ||
// Arrange | ||
var wrapped = new ArraySegment<int>(source); | ||
var expected = source | ||
.Skip(count0) | ||
.Skip(count1); | ||
|
||
// Act | ||
var result = wrapped | ||
.AsValueEnumerable() | ||
.Skip(count0) | ||
.Skip(count1); | ||
|
||
// Assert | ||
_ = result.Must() | ||
.BeEnumerableOf<int>() | ||
.BeEqualTo(expected, testRefStructs: false); | ||
result.SequenceEqual(expected).Must().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData.TakeEmpty), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.TakeSingle), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.TakeMultiple), MemberType = typeof(TestData))] | ||
public void AsValueEnumerable1_Take_With_ValidData_Must_Succeed(int[] source, int count) | ||
{ | ||
// Arrange | ||
var wrapped = new ArraySegment<int>(source); | ||
var expected = source | ||
.Take(count); | ||
|
||
// Act | ||
var result = wrapped | ||
.AsValueEnumerable() | ||
.Take(count); | ||
|
||
// Assert | ||
_ = result.Must() | ||
.BeEnumerableOf<int>() | ||
.BeEqualTo(expected, testRefStructs: false); | ||
result.SequenceEqual(expected).Must().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData.Take_Take), MemberType = typeof(TestData))] | ||
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(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData.SkipTakeEmpty), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.SkipTakeSingle), MemberType = typeof(TestData))] | ||
[MemberData(nameof(TestData.SkipTakeMultiple), MemberType = typeof(TestData))] | ||
public void AsValueEnumerable1_Sum_With_ValidData_Must_Succeed(int[] source, int skipCount, int takeCount) | ||
{ | ||
// Arrange | ||
var wrapped = new ArraySegment<int>(source); | ||
var expected = source | ||
.Skip(skipCount) | ||
.Take(takeCount) | ||
.Sum(); | ||
|
||
// Act | ||
var result = wrapped | ||
.AsValueEnumerable() | ||
.Skip(skipCount) | ||
.Take(takeCount) | ||
.Sum(); | ||
|
||
// Assert | ||
_ = result.Must() | ||
.BeEqualTo(expected); | ||
} | ||
} | ||
} |
Oops, something went wrong.