-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathRuleEvaluationTests.cs
More file actions
66 lines (62 loc) · 2.32 KB
/
RuleEvaluationTests.cs
File metadata and controls
66 lines (62 loc) · 2.32 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
using ArchUnitNET.Domain;
using ArchUnitNET.Fluent;
using ArchUnitNET.Fluent.Extensions;
using ArchUnitNET.Loader;
using ArchUnitNET.xUnit;
using Xunit;
using static ArchUnitNET.Fluent.ArchRuleDefinition;
namespace ArchUnitNET.xUnitTests
{
public class RuleEvaluationTests
{
private readonly Architecture _architecture;
private readonly string _expectedErrorMessage;
private readonly IArchRule _falseRule;
private readonly IArchRule _trueRule;
public RuleEvaluationTests()
{
_architecture = new ArchLoader()
.LoadAssemblies(System.Reflection.Assembly.Load("ArchUnitNET.xUnitTests"))
.Build();
_trueRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().Exist();
_falseRule = Classes().That().Are(typeof(RuleEvaluationTests)).Should().NotExist();
_expectedErrorMessage = _falseRule.Evaluate(_architecture).ToErrorMessage();
}
[Fact]
public void ArchRuleAssertTest()
{
ArchRuleAssert.CheckRule(_architecture, _trueRule);
Assert.Throws<FailedArchRuleException>(() =>
ArchRuleAssert.CheckRule(_architecture, _falseRule)
);
Assert.Equal(
_expectedErrorMessage,
Assert
.Throws<FailedArchRuleException>(() =>
ArchRuleAssert.CheckRule(_architecture, _falseRule)
)
.Message
);
}
[Fact]
public void ArchRuleExtensionsTest()
{
_architecture.CheckRule(_trueRule);
_trueRule.Check(_architecture);
Assert.Throws<FailedArchRuleException>(() => _architecture.CheckRule(_falseRule));
Assert.Throws<FailedArchRuleException>(() => _falseRule.Check(_architecture));
Assert.Equal(
_expectedErrorMessage,
Assert
.Throws<FailedArchRuleException>(() => _architecture.CheckRule(_falseRule))
.Message
);
Assert.Equal(
_expectedErrorMessage,
Assert
.Throws<FailedArchRuleException>(() => _falseRule.Check(_architecture))
.Message
);
}
}
}