-
Notifications
You must be signed in to change notification settings - Fork 316
Expand file tree
/
Copy pathResultOfTETests.cs
More file actions
44 lines (35 loc) · 1.36 KB
/
ResultOfTETests.cs
File metadata and controls
44 lines (35 loc) · 1.36 KB
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
34
35
36
37
38
39
40
41
42
43
44
using FluentAssertions;
using Xunit;
namespace CSharpFunctionalExtensions.Tests.ResultTests.Extensions.With
{
public class ResultOfTETests
{
[Fact]
public async void Successful_results_are_combined_with_map()
{
var r1 = Result.Success<int, string>(1);
var r2 = Result.Success<int, string>(2);
var actual = r1.WithMap(r2, (a, b) => a + b, (e1, e2) => "");
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be(3);
}
[Fact]
public async void Successful_results_are_combined_with_binding()
{
var r1 = Result.Success<int, string>(1);
var r2 = Result.Success<int, string>(2);
var actual = r1.WithBind<int, string>(r2, (a, b) => Result.Success<int, string>(a + b), (e1, e2) => "");
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be(3);
}
[Fact]
public async void Successful_results_are_combined_with_binding_different_types()
{
var r1 = Result.Success<string, string>("Hi");
var r2 = Result.Success<int, string>(2);
var actual = r1.WithBind(r2, (a, b) => Result.Success<string, string>(a + b), (e1, e2) => "");
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be("Hi2");
}
}
}