-
Notifications
You must be signed in to change notification settings - Fork 316
Expand file tree
/
Copy pathTapTests.ValueTask.Left.cs
More file actions
33 lines (27 loc) · 982 Bytes
/
TapTests.ValueTask.Left.cs
File metadata and controls
33 lines (27 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Threading.Tasks;
using CSharpFunctionalExtensions.ValueTasks;
using FluentAssertions;
using Xunit;
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions
{
public class TapTests_ValueTask_Left : MaybeTestBase
{
[Fact]
public async Task Tap_ValueTask_Lef_does_not_execute_action_if_no_value()
{
Maybe<T> maybe = null;
var executed = false;
var returnedMaybe = await maybe.AsValueTask().Tap(value => executed = true);
executed.Should().BeFalse();
returnedMaybe.HasNoValue.Should().BeTrue();
}
[Fact]
public async Task Tap_ValueTask_Lef_executes_action_if_value()
{
Maybe<T> maybe = T.Value;
var returnedMaybe = await maybe.AsValueTask().Tap(value => value.Should().Be(T.Value));
maybe.Value.Should().Be(T.Value);
returnedMaybe.Value.Should().BeSameAs(maybe.Value);
}
}
}