Skip to content

Commit 9b07ba4

Browse files
committed
The Big Bang 2
1 parent 134f70d commit 9b07ba4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+833
-573
lines changed

NetArchTest.eNhancedEdition.sln

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.3.32819.101
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest.Rules", "src\NetArchTest.Rules\NetArchTest.Rules.csproj", "{2FDD6DBD-F203-4EC9-9F9B-6771713CC353}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest", "src\NetArchTest.Rules\NetArchTest.csproj", "{2FDD6DBD-F203-4EC9-9F9B-6771713CC353}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{660FEA1B-C886-4B72-AD70-1D7DD248CD76}"
99
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest.Rules.UnitTests", "test\NetArchTest.Rules.UnitTests\NetArchTest.Rules.UnitTests.csproj", "{D56F6954-7CCA-41D6-BA81-850F0C81FE3A}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest.UnitTests", "test\NetArchTest.Rules.UnitTests\NetArchTest.UnitTests.csproj", "{D56F6954-7CCA-41D6-BA81-850F0C81FE3A}"
1111
EndProject
1212
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest.TestStructure", "test\NetArchTest.TestStructure\NetArchTest.TestStructure.csproj", "{D91C182D-DC97-4F9B-AFFE-8C7A62501DA6}"
1313
EndProject
@@ -21,6 +21,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest.CrossAssemblyTe
2121
EndProject
2222
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetArchTest.CrossAssemblyTest.B", "test\NetArchTest.CrossAssemblyTest.B\NetArchTest.CrossAssemblyTest.B.csproj", "{28692D43-3E08-43E4-BCBB-5940B9F741C6}"
2323
EndProject
24+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentation", "{AD4F8A0F-6F5B-45A6-AC8B-822999097CA3}"
25+
ProjectSection(SolutionItems) = preProject
26+
documentation\api.md = documentation\api.md
27+
api.nt = api.nt
28+
readme.md = readme.md
29+
EndProjectSection
30+
EndProject
2431
Global
2532
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2633
Debug|Any CPU = Debug|Any CPU

README.md

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,35 @@ A fluent API for .Net Standard that can enforce architectural rules in unit test
44

55
NetArchTest.eNhancedEdition is based on [NetArchTest v1.3.2](https://github.com/BenMorris/NetArchTest). If you are not familiar with NetArchTest, you should start by reading [introduction on Ben's blog](https://www.ben-morris.com/writing-archunit-style-tests-for-net-and-c-for-self-testing-architectures).
66

7-
## Rationale
7+
### Rationale
8+
9+
NetArchTest is well established mature library, but in order to push things forward, a few breaking changes had to be made, and that is how **eNhancedEdition** was born. eNhancedEdition uses almost identical Fluent API as a base library, but it is not 100% backward compatible, and it will never be. The main goal is to offer more, and not to be only a replacement.
10+
11+
### Index
12+
13+
* [Getting started](#getting-started)
14+
* [Examples](#examples)
15+
* [Writing rules](#writing-rules)
16+
* [Dependency search](#dependency-search)
17+
* [Slices](#slices)
18+
* [Custom rules](#custom-rules)
19+
* Limitations
20+
* API
21+
* [Types](documentation/api.md#types)
22+
* [Predicate](documentation/api.md#predicate)
23+
* [PredicateList](documentation/api.md#predicateList)
24+
* [Condition](documentation/api.md#condition)
25+
* [ConditionList](documentation/api.md#conditionList)
26+
* [TestResult](documentation/api.md#testResult)
27+
* [IType](documentation/api.md#itype)
28+
829

9-
NetArchTest is well established mature library, but in order to push things forward, a few breaking changes had to be made, and that is how **eNhancedEdition** has born. eNhancedEdition uses almost identical Fluent API as a base library, but it is not 100% backward compatible, and it will never be. The main goal is to offer more, and not to be a replacement.
1030

1131
## Getting started
1232

1333
The library is available as a package on NuGet: [NetArchTest.eNhancedEdition](https://www.nuget.org/packages/NetArchTest.eNhancedEdition/).
1434

15-
## Examples
35+
### Examples
1636

1737
```csharp
1838
static readonly Assembly TestCreationAssembly = typeof(Foo).Assembly;
@@ -38,7 +58,7 @@ public void DomainIsIndependent()
3858
.That()
3959
.ResideInNamespace("MyApp.Domain")
4060
.ShouldNot()
41-
.HaveDependenciesOtherThan(
61+
.HaveDependencyOtherThan(
4262
"System",
4363
"MyApp.SharedKernel.Domain",
4464
"MyApp.BuildingBlocks.Domain"
@@ -51,7 +71,7 @@ public void DomainIsIndependent()
5171

5272

5373

54-
## Writing rules
74+
### Writing rules
5575

5676
The fluent API should direct you in building up a rule, based on a combination of predicates, conditions and conjunctions.
5777

@@ -76,7 +96,34 @@ var types = result.FailingTypes;
7696
```
7797

7898

79-
## Dependencies
99+
## Dependency search
100+
101+
Dependency matrix:
102+
103+
| type\has dependency on | D1 | D2 | D3 |
104+
|---|----|----|----|
105+
| a | | | |
106+
| b | | | x |
107+
| c | | x | |
108+
| d | | x | x |
109+
| e | x | | |
110+
| f | x | | x |
111+
| g | x | x | |
112+
| h | x | x | x |
113+
114+
115+
Available predicates:
116+
117+
| | Predicate | number<br> of required<br> dependencies <br>from the list | type can have<br>a dependency<br>that is not<br>on the list | passing types | failing types |
118+
|---|---|---|---|---|---|
119+
| 1 | HaveDependencyOnAny(D1, D2) | at least 1 | yes | c, d, e, f, g, h, | a, b |
120+
| 2 | HaveDependencyOnAll(D1, D2) | all | yes | g, h | a, b, c, d, e, f |
121+
| 3 | OnlyHaveDependencyOn(D1, D2) | >=0 | no | a, c, e, g | b, d, f, h |
122+
| 1N | DoNotHaveDependencyOnAny(D1, D2) | none | yes | a, b | c, d, e, f, g, h, |
123+
| 2N | DoNotHaveDependencyOnAll(D1, D2) | not all | yes | a, b, c, d, e, f | g, h |
124+
| 3N | HaveDependencyOtherThan(D1, D2) | >=0 | yes | b, d, f, h, | a, c, e, g |
125+
126+
80127

81128
## Slices
82129

@@ -99,9 +146,9 @@ There is only one way, at least for now, to divide types into slices `ByNamespac
99146

100147
![Slices](docs/slices.png)
101148

102-
When we already have our types divided into slices, we can apply only one available right now condition: `NotHaveDependenciesBetweenSlices()`. As the name suggest it detects if any dependencies exist between slices. Any dependency from slice to type that is not part of any other slice is allowed.
149+
When we already have our types divided into slices, we can apply condition: `NotHaveDependenciesBetweenSlices()`. As the name suggest it detects if any dependency exists between slices. Dependency from slice to type that is not part of any other slice is allowed.
103150

104-
allowed | not allowed
151+
passing | failing
105152
--|---
106153
![Slices](docs/slices.ok.png)|![Slices](docs/slices.not.png)
107154

api.nt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- config.AddGeneratedFilesToVSProject = false
2+
capture output
3+
types_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Types$" | Array.First
4+
5+
predicate_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Predicate" | Array.First
6+
predicatelist_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^PredicateList" | Array.First
7+
condition_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^Condition" | Array.First
8+
conditionlist_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^ConditionList" | Array.First
9+
testresult_type = data.Classes | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^TestResult" | Array.First
10+
itype_type = data.Interfaces | Symbols.WhereNamespaceStartsWith "NetArchTest.Rules" | Symbols.WhereNameMatches "^IType" | Array.First
11+
}}
12+
# Types
13+
{{ for method in types_type.Methods | Symbols.ThatArePublic | Array.Sort "Name" }}
14+
* [{{method.Name}}](#{{method.BareName}})
15+
{{- end }}
16+
17+
# Predicate
18+
{{ for method in predicate_type.Methods | Symbols.ThatArePublic | Array.Sort "Name" }}
19+
* [{{method.Name}}](#{{method.BareName}})
20+
{{- end }}
21+
22+
# PredicateList
23+
{{ for method in predicatelist_type.Methods | Symbols.ThatArePublic | Array.Sort "Name" }}
24+
* [{{method.Name}}](#{{method.BareName}})
25+
{{- end }}
26+
27+
# Condition
28+
{{ for method in condition_type.Methods | Symbols.ThatArePublic | Array.Sort "Name" }}
29+
* [{{method.Name}}](#{{method.BareName}})
30+
{{- end }}
31+
32+
# ConditionList
33+
{{ for method in conditionlist_type.Methods | Symbols.ThatArePublic | Array.Sort "Name" }}
34+
* [{{method.Name}}](#{{method.BareName}})
35+
{{- end }}
36+
37+
# TestResult
38+
{{ for method in testresult_type.Properties | Symbols.ThatArePublic | Array.Sort "Name" }}
39+
* [{{method.Name}}](#{{method.BareName}})
40+
{{- end }}
41+
42+
# IType
43+
{{ for method in itype_type.Properties | Symbols.ThatArePublic | Array.Sort "Name" }}
44+
* [{{method.Name}}](#{{method.BareName}})
45+
{{- end }}
46+
47+
{{
48+
end
49+
Save output "documentation/api.md"
50+
-}}

documentation/api.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
2+
# Types
3+
4+
* [FromFile](#FromFile)
5+
* [FromPath](#FromPath)
6+
* [GetTypes](#GetTypes)
7+
* [InAssemblies](#InAssemblies)
8+
* [InAssembly](#InAssembly)
9+
* [InCurrentDomain](#InCurrentDomain)
10+
* [Should](#Should)
11+
* [ShouldNot](#ShouldNot)
12+
* [Slice](#Slice)
13+
* [That](#That)
14+
15+
# Predicate
16+
17+
* [AreAbstract](#AreAbstract)
18+
* [AreClasses](#AreClasses)
19+
* [AreGeneric](#AreGeneric)
20+
* [AreImmutable](#AreImmutable)
21+
* [AreInterfaces](#AreInterfaces)
22+
* [AreMutable](#AreMutable)
23+
* [AreNested](#AreNested)
24+
* [AreNestedPrivate](#AreNestedPrivate)
25+
* [AreNestedPublic](#AreNestedPublic)
26+
* [AreNotAbstract](#AreNotAbstract)
27+
* [AreNotClasses](#AreNotClasses)
28+
* [AreNotGeneric](#AreNotGeneric)
29+
* [AreNotInterfaces](#AreNotInterfaces)
30+
* [AreNotNested](#AreNotNested)
31+
* [AreNotNestedPrivate](#AreNotNestedPrivate)
32+
* [AreNotNestedPublic](#AreNotNestedPublic)
33+
* [AreNotPublic](#AreNotPublic)
34+
* [AreNotSealed](#AreNotSealed)
35+
* [AreNotStatic](#AreNotStatic)
36+
* [ArePublic](#ArePublic)
37+
* [AreSealed](#AreSealed)
38+
* [AreStatic](#AreStatic)
39+
* [DoNotHaveCustomAttribute](#DoNotHaveCustomAttribute)
40+
* [DoNotHaveCustomAttributeOrInherit](#DoNotHaveCustomAttributeOrInherit)
41+
* [DoNotHaveDependencyOnAll](#DoNotHaveDependencyOnAll)
42+
* [DoNotHaveDependencyOnAny](#DoNotHaveDependencyOnAny)
43+
* [DoNotHaveName](#DoNotHaveName)
44+
* [DoNotHaveNameEndingWith](#DoNotHaveNameEndingWith)
45+
* [DoNotHaveNameEndingWith](#DoNotHaveNameEndingWith)
46+
* [DoNotHaveNameMatching](#DoNotHaveNameMatching)
47+
* [DoNotHaveNameStartingWith](#DoNotHaveNameStartingWith)
48+
* [DoNotHaveNameStartingWith](#DoNotHaveNameStartingWith)
49+
* [DoNotImplementInterface](#DoNotImplementInterface)
50+
* [DoNotInherit](#DoNotInherit)
51+
* [DoNotResideInNamespace](#DoNotResideInNamespace)
52+
* [DoNotResideInNamespaceContaining](#DoNotResideInNamespaceContaining)
53+
* [DoNotResideInNamespaceEndingWith](#DoNotResideInNamespaceEndingWith)
54+
* [DoNotResideInNamespaceMatching](#DoNotResideInNamespaceMatching)
55+
* [DoNotResideInNamespaceStartingWith](#DoNotResideInNamespaceStartingWith)
56+
* [HaveCustomAttribute](#HaveCustomAttribute)
57+
* [HaveCustomAttributeOrInherit](#HaveCustomAttributeOrInherit)
58+
* [HaveDependencyOnAll](#HaveDependencyOnAll)
59+
* [HaveDependencyOnAny](#HaveDependencyOnAny)
60+
* [HaveDependencyOtherThan](#HaveDependencyOtherThan)
61+
* [HaveName](#HaveName)
62+
* [HaveNameEndingWith](#HaveNameEndingWith)
63+
* [HaveNameEndingWith](#HaveNameEndingWith)
64+
* [HaveNameMatching](#HaveNameMatching)
65+
* [HaveNameStartingWith](#HaveNameStartingWith)
66+
* [HaveNameStartingWith](#HaveNameStartingWith)
67+
* [HaveSomeNonNullableMembers](#HaveSomeNonNullableMembers)
68+
* [ImplementInterface](#ImplementInterface)
69+
* [Inherit](#Inherit)
70+
* [MeetCustomRule](#MeetCustomRule)
71+
* [OnlyHaveDependencyOn](#OnlyHaveDependencyOn)
72+
* [OnlyHaveNullableMembers](#OnlyHaveNullableMembers)
73+
* [ResideInNamespace](#ResideInNamespace)
74+
* [ResideInNamespaceContaining](#ResideInNamespaceContaining)
75+
* [ResideInNamespaceEndingWith](#ResideInNamespaceEndingWith)
76+
* [ResideInNamespaceMatching](#ResideInNamespaceMatching)
77+
* [ResideInNamespaceStartingWith](#ResideInNamespaceStartingWith)
78+
79+
# PredicateList
80+
81+
* [And](#And)
82+
* [GetTypes](#GetTypes)
83+
* [Or](#Or)
84+
* [Should](#Should)
85+
* [ShouldNot](#ShouldNot)
86+
* [Slice](#Slice)
87+
88+
# Condition
89+
90+
* [BeAbstract](#BeAbstract)
91+
* [BeClasses](#BeClasses)
92+
* [BeGeneric](#BeGeneric)
93+
* [BeImmutable](#BeImmutable)
94+
* [BeInterfaces](#BeInterfaces)
95+
* [BeMutable](#BeMutable)
96+
* [BeNested](#BeNested)
97+
* [BeNestedPrivate](#BeNestedPrivate)
98+
* [BeNestedPublic](#BeNestedPublic)
99+
* [BePublic](#BePublic)
100+
* [BeSealed](#BeSealed)
101+
* [BeStatic](#BeStatic)
102+
* [HaveCustomAttribute](#HaveCustomAttribute)
103+
* [HaveCustomAttributeOrInherit](#HaveCustomAttributeOrInherit)
104+
* [HaveDependencyOnAll](#HaveDependencyOnAll)
105+
* [HaveDependencyOnAny](#HaveDependencyOnAny)
106+
* [HaveDependencyOtherThan](#HaveDependencyOtherThan)
107+
* [HaveName](#HaveName)
108+
* [HaveNameEndingWith](#HaveNameEndingWith)
109+
* [HaveNameEndingWith](#HaveNameEndingWith)
110+
* [HaveNameMatching](#HaveNameMatching)
111+
* [HaveNameStartingWith](#HaveNameStartingWith)
112+
* [HaveNameStartingWith](#HaveNameStartingWith)
113+
* [HaveSomeNonNullableMembers](#HaveSomeNonNullableMembers)
114+
* [ImplementInterface](#ImplementInterface)
115+
* [Inherit](#Inherit)
116+
* [MeetCustomRule](#MeetCustomRule)
117+
* [NotBeAbstract](#NotBeAbstract)
118+
* [NotBeClasses](#NotBeClasses)
119+
* [NotBeGeneric](#NotBeGeneric)
120+
* [NotBeInterfaces](#NotBeInterfaces)
121+
* [NotBeNested](#NotBeNested)
122+
* [NotBeNestedPrivate](#NotBeNestedPrivate)
123+
* [NotBeNestedPublic](#NotBeNestedPublic)
124+
* [NotBePublic](#NotBePublic)
125+
* [NotBeSealed](#NotBeSealed)
126+
* [NotBeStatic](#NotBeStatic)
127+
* [NotHaveCustomAttribute](#NotHaveCustomAttribute)
128+
* [NotHaveCustomAttributeOrInherit](#NotHaveCustomAttributeOrInherit)
129+
* [NotHaveDependencyOnAll](#NotHaveDependencyOnAll)
130+
* [NotHaveDependencyOnAny](#NotHaveDependencyOnAny)
131+
* [NotHaveName](#NotHaveName)
132+
* [NotHaveNameEndingWith](#NotHaveNameEndingWith)
133+
* [NotHaveNameEndingWith](#NotHaveNameEndingWith)
134+
* [NotHaveNameMatching](#NotHaveNameMatching)
135+
* [NotHaveNameStartingWith](#NotHaveNameStartingWith)
136+
* [NotHaveNameStartingWith](#NotHaveNameStartingWith)
137+
* [NotImplementInterface](#NotImplementInterface)
138+
* [NotInherit](#NotInherit)
139+
* [NotResideInNamespace](#NotResideInNamespace)
140+
* [NotResideInNamespaceContaining](#NotResideInNamespaceContaining)
141+
* [NotResideInNamespaceEndingWith](#NotResideInNamespaceEndingWith)
142+
* [NotResideInNamespaceMatching](#NotResideInNamespaceMatching)
143+
* [NotResideInNamespaceStartingWith](#NotResideInNamespaceStartingWith)
144+
* [OnlyHaveDependencyOn](#OnlyHaveDependencyOn)
145+
* [OnlyHaveNullableMembers](#OnlyHaveNullableMembers)
146+
* [ResideInNamespace](#ResideInNamespace)
147+
* [ResideInNamespaceContaining](#ResideInNamespaceContaining)
148+
* [ResideInNamespaceEndingWith](#ResideInNamespaceEndingWith)
149+
* [ResideInNamespaceMatching](#ResideInNamespaceMatching)
150+
* [ResideInNamespaceStartingWith](#ResideInNamespaceStartingWith)
151+
152+
# ConditionList
153+
154+
* [And](#And)
155+
* [GetResult](#GetResult)
156+
* [GetTypes](#GetTypes)
157+
* [Or](#Or)
158+
159+
# TestResult
160+
161+
* [FailingTypes](#FailingTypes)
162+
* [IsSuccessful](#IsSuccessful)
163+
164+
# IType
165+
166+
* [FullName](#FullName)
167+
* [Name](#Name)
168+
* [ReflectionType](#ReflectionType)
169+

documentation/api.nt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


samples/NetArchTest.SampleRules/ExamplePolicies.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Linq;
66
using System.Threading.Tasks;
77
using NetArchTest.Rules;
8-
using NetArchTest.Rules.Policies;
8+
using NetArchTest.Policies;
99
using NetArchTest.SampleLibrary.Data;
1010
using NetArchTest.SampleLibrary.Services;
1111

samples/NetArchTest.SampleRules/NetArchTest.SampleRules.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<ProjectReference Include="..\..\src\NetArchTest.Rules\NetArchTest.Rules.csproj" />
9+
<ProjectReference Include="..\..\src\NetArchTest.Rules\NetArchTest.csproj" />
1010
<ProjectReference Include="..\NetArchTest.SampleLibrary\NetArchTest.SampleLibrary.csproj" />
1111
</ItemGroup>
1212

src/NetArchTest.Rules/Assemblies/TypeSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using System.Linq;
44
using System.Reflection;
55
using Mono.Cecil;
6-
using NetArchTest.Rules.Dependencies.DataStructures;
6+
using NetArchTest.Dependencies.DataStructures;
77
using NetArchTest.Rules.Extensions;
88

9-
namespace NetArchTest.Rules.Assemblies
9+
namespace NetArchTest.Assemblies
1010
{
1111
internal sealed class TypeSource
1212
{

src/NetArchTest.Rules/Assemblies/TypeSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Mono.Cecil;
22

3-
namespace NetArchTest.Rules.Assemblies
3+
namespace NetArchTest.Assemblies
44
{
55
internal sealed class TypeSpec
66
{

0 commit comments

Comments
 (0)