-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomainErrorTests.cs
More file actions
75 lines (60 loc) · 1.75 KB
/
Copy pathDomainErrorTests.cs
File metadata and controls
75 lines (60 loc) · 1.75 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
namespace Company.Template.Domain.Tests.Common;
public sealed class DomainErrorTests
{
[Fact]
public void None_ReturnsNoneDomainError()
{
// Arrange
// Act
DomainError error = DomainError.None;
// Assert
error.IsNone.ShouldBeTrue();
error.Code.ShouldBe(DomainErrorCode.None);
error.Message.ShouldBe("No domain error.");
}
[Fact]
public void Create_WithCodeAndMessage_ReturnsDomainError()
{
// Arrange
// Act
DomainError error = DomainError.Create(
DomainErrorCodes.AmountNegative,
"Amount cannot be negative.");
// Assert
error.IsNone.ShouldBeFalse();
error.Code.ShouldBe(DomainErrorCodes.AmountNegative);
error.Message.ShouldBe("Amount cannot be negative.");
}
[Fact]
public void Create_WithNullCode_ThrowsArgumentNullException()
{
// Arrange
// Act
Action action = () => DomainError.Create(null!, "Amount cannot be negative.");
// Assert
action.ShouldThrow<ArgumentNullException>();
}
[Fact]
public void Create_WithNoneCode_ThrowsArgumentException()
{
// Arrange
// Act
Action action = () => DomainError.Create(
DomainErrorCode.None,
"Some error.");
// Assert
action.ShouldThrow<ArgumentException>();
}
[Theory]
[InlineData("")]
[InlineData(" ")]
[InlineData("\t")]
public void Create_WithMissingMessage_ThrowsArgumentException(string message)
{
// Arrange
// Act
Action action = () => DomainError.Create(DomainErrorCodes.AmountNegative, message);
// Assert
action.ShouldThrow<ArgumentException>();
}
}