-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from pfpack/release/v1.2.0-preview.1.0.0
release/v1.2.0-preview.1.0.0
- Loading branch information
Showing
11 changed files
with
95 additions
and
15 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
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
18 changes: 18 additions & 0 deletions
18
src/primitives/Primitives.Tests/Linq/YielderTypedTest/YielderTypedTest.Empty.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,18 @@ | ||
#nullable enable | ||
|
||
using NUnit.Framework; | ||
using PrimeFuncPack.UnitTest; | ||
using System.Linq; | ||
|
||
namespace PrimeFuncPack.Primitives.Tests | ||
{ | ||
partial class YielderTypedTest | ||
{ | ||
[Test] | ||
public void YieldEmpty_ExpectEmptyCollection() | ||
{ | ||
var actual = Yielder<StructType?>.YieldEmpty(); | ||
Assert.IsEmpty(actual); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/primitives/Primitives.Tests/Linq/YielderTypedTest/YielderTypedTest.Single.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,32 @@ | ||
#nullable enable | ||
|
||
using NUnit.Framework; | ||
using System.Linq; | ||
|
||
namespace PrimeFuncPack.Primitives.Tests | ||
{ | ||
partial class YielderTypedTest | ||
{ | ||
[Test] | ||
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] | ||
public void YieldSingle_ExpectCollectionLengthEqualsOne( | ||
object? sourceValue) | ||
{ | ||
var actual = Yielder<object?>.YieldSingle(sourceValue); | ||
|
||
var actualLength = actual.Count(); | ||
Assert.AreEqual(1, actualLength); | ||
} | ||
|
||
[Test] | ||
[TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] | ||
public void YieldSingle_ExpectFirstItemIsSameAsSourceValue( | ||
object? sourceValue) | ||
{ | ||
var actual = Yielder<object?>.YieldSingle(sourceValue); | ||
|
||
var actualFirst = actual.FirstOrDefault(); | ||
Assert.AreSame(sourceValue, actualFirst); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/primitives/Primitives.Tests/Linq/YielderTypedTest/YielderTypedTest.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,8 @@ | ||
#nullable enable | ||
|
||
namespace PrimeFuncPack.Primitives.Tests | ||
{ | ||
public sealed partial class YielderTypedTest | ||
{ | ||
} | ||
} |
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
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,19 @@ | ||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace System.Linq | ||
{ | ||
public static class Yielder<T> | ||
{ | ||
public static IEnumerable<T> YieldSingle(T value) | ||
{ | ||
yield return value; | ||
} | ||
|
||
public static IEnumerable<T> YieldEmpty() | ||
{ | ||
yield break; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Linq | ||
{ | ||
public static class Yielder | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static IEnumerable<T> YieldSingle<T>(T value) | ||
{ | ||
yield return value; | ||
} | ||
=> | ||
Yielder<T>.YieldSingle(value); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static IEnumerable<T> YieldEmpty<T>() | ||
{ | ||
yield break; | ||
} | ||
=> | ||
Yielder<T>.YieldEmpty(); | ||
} | ||
} |
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