-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathDescriptionTests.cs
More file actions
89 lines (81 loc) · 3 KB
/
DescriptionTests.cs
File metadata and controls
89 lines (81 loc) · 3 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using ArchUnitNET.Fluent;
using Xunit;
using static ArchUnitNET.Fluent.ArchRuleDefinition;
namespace ArchUnitNETTests.Fluent
{
public class DescriptionTests
{
private readonly IArchRule _descriptionTestRule = Classes()
.That()
.HaveNameStartingWith("test")
.Because("reason1")
.And()
.AreNotNested()
.Should()
.BeAbstract()
.Because("reason2")
.OrShould()
.NotBeAbstract()
.And(Types().Should().BeNested())
.Or()
.Attributes()
.Should()
.Exist()
.Because("reason3");
private readonly IArchRule _customDescriptionTestRule1 = Classes()
.Should()
.BeAbstract()
.As(CustomDescription);
private readonly IArchRule _customDescriptionTestRule2 = Classes()
.That()
.ArePublic()
.As(CustomDescription)
.And()
.AreProtected()
.Should()
.BePublic()
.AndShould()
.BeAbstract()
.As(CustomDescription);
private readonly IArchRule _combinedCustomDescriptionTestRule = Classes()
.Should()
.BeAbstract()
.As(CustomDescription)
.And()
.Attributes()
.Should()
.BeAbstract()
.As(CustomDescription);
private const string ExpectedDescription =
"Classes that have name starting with \"test\" because reason1 and are not nested should be abstract because reason2 or should not be abstract and Types should be nested or Attributes should exist because reason3";
private const string CustomDescription = "custom description";
[Fact]
public void CustomDescriptionTest()
{
Assert.Equal("Classes " + CustomDescription, _customDescriptionTestRule1.Description);
Assert.Equal("Classes " + CustomDescription, _customDescriptionTestRule1.ToString());
Assert.Equal(
CustomDescription + " and are protected " + CustomDescription,
_customDescriptionTestRule2.Description
);
Assert.Equal(
CustomDescription + " and are protected " + CustomDescription,
_customDescriptionTestRule2.ToString()
);
Assert.Equal(
"Classes " + CustomDescription + " and Attributes " + CustomDescription,
_combinedCustomDescriptionTestRule.Description
);
Assert.Equal(
"Classes " + CustomDescription + " and Attributes " + CustomDescription,
_combinedCustomDescriptionTestRule.ToString()
);
}
[Fact]
public void DescriptionTest()
{
Assert.Equal(ExpectedDescription, _descriptionTestRule.Description);
Assert.Equal(ExpectedDescription, _descriptionTestRule.ToString());
}
}
}