-
Notifications
You must be signed in to change notification settings - Fork 3
/
ResultLinqExtensionsTests.cs
57 lines (48 loc) · 1.43 KB
/
ResultLinqExtensionsTests.cs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
using FluentAssertions;
using Xunit;
namespace ResultSharp.Tests;
public class ResultLinqExtensionsTests
{
[Fact]
public void SelectMany_ResultTE_Ok()
{
var result =
from a in Result.Ok<string, string>("foo")
from b in Result.Ok<int, string>(123)
from c in Result.Ok<string, string>("bar")
select (a, b, c);
result.Unwrap().Should().Be(("foo", 123, "bar"));
}
[Fact]
public void SelectMany_ResultTE_Err()
{
var result =
from a in Result.Ok<string, string>("ok")
from b in Result.Err<string, string>("err1")
from c in Result.Ok<string, string>("ok")
from d in Result.Err<string, string>("err2")
select (a, b, c);
result.UnwrapErr().Should().Be("err1");
}
[Fact]
public void SelectMany_ResultT_Ok()
{
var result =
from a in Result.Ok("foo")
from b in Result.Ok(123)
from c in Result.Ok("bar")
select (a, b, c);
result.Unwrap().Should().Be(("foo", 123, "bar"));
}
[Fact]
public void SelectMany_ResultT_Err()
{
var result =
from a in Result.Ok("ok")
from b in Result.Err<string>("err1")
from c in Result.Ok("ok")
from d in Result.Err<string>("err2")
select (a, b, c);
result.UnwrapErr().Should().Be("err1");
}
}