-
Notifications
You must be signed in to change notification settings - Fork 316
Expand file tree
/
Copy pathAsyncResultOfTETests.cs
More file actions
32 lines (27 loc) · 993 Bytes
/
AsyncResultOfTETests.cs
File metadata and controls
32 lines (27 loc) · 993 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
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;
namespace CSharpFunctionalExtensions.Tests.ResultTests.Extensions.With
{
public class AsyncResultOfTETests
{
[Fact]
public async Task Combining_successful()
{
var r1 = Result.Success<int, string>(1);
var r2 = Result.Success<int, string>(2);
var actual = await r1.WithMap(r2, (a, b) => Task.FromResult(a + b), (e1, e2) => "failure");
actual.IsSuccess.Should().BeTrue();
}
[Fact]
public async Task Successful_results_are_combined_with_binding()
{
var r1 = Result.Success<int, string>(1);
var r2 = Result.Success<int, string>(2);
var actual = await r1
.WithBind(r2, (a, b) => Task.FromResult(Result.Success<int, string>(a + b)), (e1, e2) => "error");
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be(3);
}
}
}