-
-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathReasonHaveMetadataTests.cs
More file actions
59 lines (51 loc) · 2.35 KB
/
ReasonHaveMetadataTests.cs
File metadata and controls
59 lines (51 loc) · 2.35 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
namespace FluentResults.Extensions.AwesomeAssertions.Test.ResultTests
{
public class ReasonHaveMetadataTests
{
[Fact]
public void A_result_with_reason_with_specific_metadata_throw_no_exception()
{
var failedResult = Result.Fail(new SomeReason("Error 1")
.WithMetadata("key", "value"));
Action action = () => failedResult
.Should()
.BeFailure()
.And.HaveReason("Error 1")
.That.HaveMetadata("key", "value");
action.Should().NotThrow();
}
[Theory]
[InlineData(null)]
[InlineData("value1")]
[InlineData(1)]
public void A_result_with_reason_with_another_metadata_because_of_value_throw_exception(object expectedMetadataValue)
{
var failedResult = Result.Fail(new SomeReason("Error 1")
.WithMetadata("key", "value"));
Action action = () => failedResult
.Should()
.BeFailure()
.And.HaveReason("Error 1")
.That.HaveMetadata("key", expectedMetadataValue);
action.Should()
.Throw<XunitException>()
.WithMessage($"Reason should contain 'key' with '{expectedMetadataValue}', but not contain it");
}
[Theory]
[InlineData("ke")]
[InlineData("key1")]
public void A_result_with_reason_with_another_metadata_because_of_key_throw_exception(string expectedMetadataKey)
{
var failedResult = Result.Fail(new SomeReason("Error 1")
.WithMetadata("key", "value"));
Action action = () => failedResult
.Should()
.BeFailure()
.And.HaveReason("Error 1")
.That.HaveMetadata(expectedMetadataKey, "value");
action.Should()
.Throw<XunitException>()
.WithMessage($"Reason should contain '{expectedMetadataKey}' with 'value', but not contain it");
}
}
}