-
Notifications
You must be signed in to change notification settings - Fork 316
Expand file tree
/
Copy pathResultOfTTest.cs
More file actions
41 lines (35 loc) · 1.2 KB
/
ResultOfTTest.cs
File metadata and controls
41 lines (35 loc) · 1.2 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
using FluentAssertions;
using Xunit;
namespace CSharpFunctionalExtensions.Tests.ResultTests.Extensions.With
{
public class ResultOfTTest
{
[Fact]
public void Results_of_same_type_are_combined_correctly()
{
var r1 = Result.Success("Hello");
var r2 = Result.Success("world");
var actual = r1.With(r2);
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be(("Hello", "world"));
}
[Fact]
public void Results_of_different_type_are_mapped_correctly()
{
var r1 = Result.Success("Hello");
var r2 = Result.Success("world");
var actual = r1.WithMap(r2, (a, b) => a + b);
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be("Helloworld");
}
[Fact]
public void Results_of_different_type_are_bound_correctly()
{
var r1 = Result.Success("Hello");
var r2 = Result.Success("world");
var actual = r1.WithBind(r2, (a, b) => Result.Success(a + b));
actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be("Helloworld");
}
}
}