Skip to content

Commit c960c10

Browse files
test: rewrite type syntax elements tests
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
1 parent f579eff commit c960c10

41 files changed

Lines changed: 5214 additions & 1774 deletions

File tree

Some content is hidden

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

ArchUnit.sln

Lines changed: 220 additions & 7 deletions
Large diffs are not rendered by default.

ArchUnitNETTests/ArchUnitNET/Storage/FrozenRules.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
<Violation>Slice1</Violation>
2020
<Violation>Slice1.Service</Violation>
2121
</FrozenRule>
22-
</FrozenRules>
22+
</FrozenRules>

ArchUnitNETTests/ArchUnitNETTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
</PropertyGroup>
1515
<ItemGroup>
1616
<ProjectReference Include="..\ArchUnitNET.xUnit\ArchUnitNET.xUnit.csproj" />
17-
<ProjectReference Include="..\TestAssemblies\InterfaceAssembly\InterfaceAssembly.csproj" />
1817
<ProjectReference Include="..\TestAssembly\TestAssembly.csproj" />
1918
<ProjectReference Include="..\TestAssemblies\AttributeAssembly\AttributeAssembly.csproj" />
2019
<ProjectReference Include="..\TestAssemblies\TypeDependencyAssembly\TypeDependencyAssembly.csproj" />
@@ -32,6 +31,7 @@
3231
Aliases="global,OtherLoaderTestAssemblyAlias"
3332
/>
3433
<ProjectReference Include="..\TestAssemblies\VisibilityAssembly\VisibilityAssembly.csproj" />
34+
<ProjectReference Include="..\TestAssemblies\TypeAssembly\TypeAssembly.csproj" />
3535
</ItemGroup>
3636
<ItemGroup>
3737
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />

ArchUnitNETTests/AssemblyTestHelper/InterfaceAssemblyTestHelper.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
using System;
2+
using System.Linq;
3+
using ArchUnitNET.Domain;
4+
using ArchUnitNET.Domain.Extensions;
5+
using TypeNamespace;
6+
7+
namespace ArchUnitNETTests.AssemblyTestHelper;
8+
9+
public class TypeAssemblyTestHelper : AssemblyTestHelper
10+
{
11+
public sealed override Architecture Architecture => StaticTestArchitectures.TypeArchitecture;
12+
13+
// Enums
14+
public IType SimpleEnum;
15+
public Type SimpleEnumSystemType = typeof(SimpleEnum);
16+
17+
public IType OtherEnum;
18+
public Type OtherEnumSystemType = typeof(OtherEnum);
19+
20+
// Structs
21+
public IType SimpleStruct;
22+
public Type SimpleStructSystemType = typeof(SimpleStruct);
23+
24+
public IType OtherStruct;
25+
public Type OtherStructSystemType = typeof(OtherStruct);
26+
27+
// Regular classes
28+
public Class RegularClass;
29+
public Type RegularClassSystemType = typeof(RegularClass);
30+
31+
public Class OtherRegularClass;
32+
public Type OtherRegularClassSystemType = typeof(OtherRegularClass);
33+
34+
// Member classes
35+
public Class ClassWithProperty;
36+
public Type ClassWithPropertySystemType = typeof(ClassWithProperty);
37+
38+
public Class ClassWithField;
39+
public Type ClassWithFieldSystemType = typeof(ClassWithField);
40+
41+
public Class ClassWithMethod;
42+
public Type ClassWithMethodSystemType = typeof(ClassWithMethod);
43+
44+
public Class ClassWithAllMembers;
45+
public Type ClassWithAllMembersSystemType = typeof(ClassWithAllMembers);
46+
47+
public Class ClassWithoutMembers;
48+
public Type ClassWithoutMembersSystemType = typeof(ClassWithoutMembers);
49+
50+
// Nested classes
51+
public Class OuterClassA;
52+
public Type OuterClassASystemType = typeof(OuterClassA);
53+
54+
public Class OuterClassB;
55+
public Type OuterClassBSystemType = typeof(OuterClassB);
56+
57+
public Class InnerClassA;
58+
public Type InnerClassASystemType = typeof(OuterClassA.InnerClassA);
59+
60+
public Class OtherInnerClassA;
61+
public Type OtherInnerClassASystemType = typeof(OuterClassA.OtherInnerClassA);
62+
63+
public Class InnerClassB;
64+
public Type InnerClassBSystemType = typeof(OuterClassB.InnerClassB);
65+
66+
public Class NonNestedClass;
67+
public Type NonNestedClassSystemType = typeof(NonNestedClass);
68+
69+
// Interfaces
70+
public Interface TestInterface;
71+
public Type TestInterfaceSystemType = typeof(ITestInterface);
72+
73+
public Interface OtherTestInterface;
74+
public Type OtherTestInterfaceSystemType = typeof(IOtherTestInterface);
75+
76+
public Interface ChildTestInterface;
77+
public Type ChildTestInterfaceSystemType = typeof(IChildTestInterface);
78+
79+
public Interface OtherChildTestInterface;
80+
public Type OtherChildTestInterfaceSystemType = typeof(IOtherChildTestInterface);
81+
82+
public Interface MultiParentTestInterface;
83+
public Type MultiParentTestInterfaceSystemType = typeof(IMultiParentTestInterface);
84+
85+
public Interface StandaloneTestInterface;
86+
public Type StandaloneTestInterfaceSystemType = typeof(IStandaloneTestInterface);
87+
88+
// Interface implementation
89+
public Class ClassImplementingInterface;
90+
public Type ClassImplementingInterfaceSystemType = typeof(ClassImplementingInterface);
91+
92+
public Class ClassNotImplementingInterface;
93+
public Type ClassNotImplementingInterfaceSystemType = typeof(ClassNotImplementingInterface);
94+
95+
// Assignability
96+
public Class BaseClassForAssign;
97+
public Type BaseClassForAssignSystemType = typeof(BaseClassForAssign);
98+
99+
public Class OtherBaseClassForAssign;
100+
public Type OtherBaseClassForAssignSystemType = typeof(OtherBaseClassForAssign);
101+
102+
public Class DerivedClassForAssign;
103+
public Type DerivedClassForAssignSystemType = typeof(DerivedClassForAssign);
104+
105+
public Class OtherDerivedClassForAssign;
106+
public Type OtherDerivedClassForAssignSystemType = typeof(OtherDerivedClassForAssign);
107+
108+
public Class UnrelatedClassForAssign;
109+
public Type UnrelatedClassForAssignSystemType = typeof(UnrelatedClassForAssign);
110+
111+
public Class OtherUnrelatedClassForAssign;
112+
public Type OtherUnrelatedClassForAssignSystemType = typeof(OtherUnrelatedClassForAssign);
113+
114+
public TypeAssemblyTestHelper()
115+
{
116+
SimpleEnum = Architecture.GetITypeOfType(typeof(SimpleEnum));
117+
OtherEnum = Architecture.GetITypeOfType(typeof(OtherEnum));
118+
SimpleStruct = Architecture.GetITypeOfType(typeof(SimpleStruct));
119+
OtherStruct = Architecture.GetITypeOfType(typeof(OtherStruct));
120+
121+
RegularClass = Architecture.GetClassOfType(typeof(RegularClass));
122+
OtherRegularClass = Architecture.GetClassOfType(typeof(OtherRegularClass));
123+
124+
ClassWithProperty = Architecture.GetClassOfType(typeof(ClassWithProperty));
125+
ClassWithField = Architecture.GetClassOfType(typeof(ClassWithField));
126+
ClassWithMethod = Architecture.GetClassOfType(typeof(ClassWithMethod));
127+
ClassWithAllMembers = Architecture.GetClassOfType(typeof(ClassWithAllMembers));
128+
ClassWithoutMembers = Architecture.GetClassOfType(typeof(ClassWithoutMembers));
129+
130+
OuterClassA = Architecture.GetClassOfType(typeof(OuterClassA));
131+
OuterClassB = Architecture.GetClassOfType(typeof(OuterClassB));
132+
InnerClassA = Architecture.GetClassOfType(typeof(OuterClassA.InnerClassA));
133+
OtherInnerClassA = Architecture.GetClassOfType(typeof(OuterClassA.OtherInnerClassA));
134+
InnerClassB = Architecture.GetClassOfType(typeof(OuterClassB.InnerClassB));
135+
NonNestedClass = Architecture.GetClassOfType(typeof(NonNestedClass));
136+
137+
TestInterface = Architecture.GetInterfaceOfType(typeof(ITestInterface));
138+
OtherTestInterface = Architecture.GetInterfaceOfType(typeof(IOtherTestInterface));
139+
ChildTestInterface = Architecture.GetInterfaceOfType(typeof(IChildTestInterface));
140+
OtherChildTestInterface = Architecture.GetInterfaceOfType(typeof(IOtherChildTestInterface));
141+
MultiParentTestInterface = Architecture.GetInterfaceOfType(
142+
typeof(IMultiParentTestInterface)
143+
);
144+
StandaloneTestInterface = Architecture.GetInterfaceOfType(typeof(IStandaloneTestInterface));
145+
146+
ClassImplementingInterface = Architecture.GetClassOfType(
147+
typeof(ClassImplementingInterface)
148+
);
149+
ClassNotImplementingInterface = Architecture.GetClassOfType(
150+
typeof(ClassNotImplementingInterface)
151+
);
152+
153+
BaseClassForAssign = Architecture.GetClassOfType(typeof(BaseClassForAssign));
154+
OtherBaseClassForAssign = Architecture.GetClassOfType(typeof(OtherBaseClassForAssign));
155+
DerivedClassForAssign = Architecture.GetClassOfType(typeof(DerivedClassForAssign));
156+
OtherDerivedClassForAssign = Architecture.GetClassOfType(
157+
typeof(OtherDerivedClassForAssign)
158+
);
159+
UnrelatedClassForAssign = Architecture.GetClassOfType(typeof(UnrelatedClassForAssign));
160+
OtherUnrelatedClassForAssign = Architecture.GetClassOfType(
161+
typeof(OtherUnrelatedClassForAssign)
162+
);
163+
}
164+
}

0 commit comments

Comments
 (0)