-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce async variant of Option.Map (#45)
* upgrade target framework * introduce async option for map * upgrade workflow to use .net 8
- Loading branch information
Showing
5 changed files
with
52 additions
and
3 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
2 changes: 1 addition & 1 deletion
2
Galaxus.Functional.NUnit.Test/Galaxus.Functional.NUnit.Test.csproj
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
45 changes: 45 additions & 0 deletions
45
Galaxus.Functional.Tests/Option/Async/AsyncOptionExtensions.MapTest.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,45 @@ | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Galaxus.Functional.Tests.Option.Async; | ||
|
||
[TestFixture] | ||
internal class AsyncOptionExtensions_MapTest | ||
{ | ||
public sealed class MapAsyncTest | ||
{ | ||
[Test] | ||
public async Task TestMapAsync_WhenSelfIsSome() | ||
{ | ||
var mapInvoked = false; | ||
|
||
var subject = "value".ToOption(); | ||
var value = await subject.MapAsync( | ||
s => Task.Run(() => | ||
{ | ||
mapInvoked = true; | ||
return s.Length.ToOption(); | ||
})); | ||
|
||
Assert.AreEqual(5.ToOption(), value); | ||
Assert.IsTrue(mapInvoked); | ||
} | ||
|
||
[Test] | ||
public async Task TestMapAsync_WhenSelfIsNone() | ||
{ | ||
var mapInvoked = false; | ||
|
||
var subject = Option<string>.None; | ||
var value = await subject.MapAsync( | ||
s => Task.Run(() => | ||
{ | ||
mapInvoked = true; | ||
return s.Length.ToOption(); | ||
})); | ||
|
||
Assert.AreEqual(Option<int>.None, value); | ||
Assert.IsFalse(mapInvoked); | ||
} | ||
} | ||
} |
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