-
Notifications
You must be signed in to change notification settings - Fork 3
/
ResultMethodsTests.cs
62 lines (49 loc) · 1.4 KB
/
ResultMethodsTests.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
58
59
60
61
62
using FluentAssertions;
using Xunit;
using static ResultSharp.Prelude;
namespace ResultSharp.Tests;
public class ResultMethodsTests
{
[Fact]
public void OkIf_TrueCondition_ReturnsOkResult()
{
var expected = Ok(10);
var actual = Result.OkIf(true, 10, "foo");
actual.Should().Be(expected);
}
[Fact]
public void ErrIf_TrueCondition_ReturnsFaultedResult()
{
var expected = Err("foo");
var actual = Result.ErrIf(true, 0, "foo");
actual.Should().Be(expected);
}
[Fact]
public void OkIf_TrueConditionWithNonStringErrType_ReturnsOkResult()
{
var expected = Ok("foo");
var actual = Result.OkIf(true, "foo", -1);
actual.Should().Be(expected);
}
[Fact]
public void ErrIf_TrueConditionWithNonStringErrType_ReturnsFaultedResult()
{
var expected = Err(-1);
var actual = Result.ErrIf(true, "foo", -1);
actual.Should().Be(expected);
}
[Fact]
public void OkIf_TrueConditionWithoutOkValue_ReturnsOkResult()
{
var expected = Result.Ok();
var actual = Result.OkIf(true, "foo");
actual.Should().Be(expected);
}
[Fact]
public void ErrIf_TrueConditionWithoutOkValue_ReturnsFaultedResult()
{
var expected = Result.Err("foo");
var actual = Result.ErrIf(true, "foo");
actual.Should().Be(expected);
}
}