Skip to content

Commit 898cfb0

Browse files
Merge pull request #375 from TNG/ci/refactor-attribute-assembly
Refactor AttributeAssembly
2 parents cc39e12 + 61897eb commit 898cfb0

18 files changed

+1323
-1319
lines changed
Lines changed: 86 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,126 @@
11
using System.Linq;
22
using ArchUnitNET.Domain;
33
using ArchUnitNET.Domain.Extensions;
4+
using ArchUnitNET.Loader;
45
using AttributeNamespace;
56

67
namespace ArchUnitNETTests.AssemblyTestHelper;
78

89
public class AttributeAssemblyTestHelpers : AssemblyTestHelper
910
{
10-
public override Architecture Architecture
11-
{
12-
get => StaticTestArchitectures.AttributeArchitecture;
13-
}
14-
15-
public string NonExistentAttributeValue = "NotTheValueOfAnyAttribute";
16-
17-
public object Attribute1Parameter1Value = "Argument";
18-
public object Attribute1Parameter2Value = 0;
19-
public object Attribute1Parameter3Value = typeof(TypeArgument);
20-
public object Attribute1Parameter3InvalidValue = typeof(OtherTypeArgument);
21-
22-
public string Attribute1NamedParameter1Name = "NamedParameter1";
23-
public object Attribute1NamedParameter1Value = typeof(NamedTypeArgument);
24-
public (string, object) Attribute1NamedParameter1Pair = (
25-
"NamedParameter1",
26-
typeof(NamedTypeArgument)
27-
);
28-
public (string, object) Attribute1NamedParameter1InvalidNamePair = (
29-
"OtherNamedParameter1",
30-
typeof(NamedTypeArgument)
31-
);
32-
public (string, object) Attribute1NamedParameter1InvalidValuePair = (
33-
"NamedParameter1",
34-
typeof(OtherNamedTypeArgument)
35-
);
36-
public string Attribute1NamedParameter2Name = "NamedParameter2";
37-
public object Attribute1NamedParameter2Value = "NamedArgument";
38-
public (string, object) Attribute1NamedParameter2Pair = ("NamedParameter2", "NamedArgument");
39-
public (string, object) Attribute1NamedParameter2InvalidNamePair = (
40-
"OtherNamedParameter2",
41-
"NamedArgument"
42-
);
43-
public (string, object) Attribute1NamedParameter2InvalidValuePair = (
44-
"NamedParameter2",
45-
"OtherNamedArgument"
46-
);
47-
public string Attribute1NamedParameter3Name = "NamedParameter3";
48-
public object Attribute1NamedParameter3Value = 1;
49-
public (string, object) Attribute1NamedParameter3Pair = ("NamedParameter3", 1);
50-
51-
public object Attribute2Parameter1Value = typeof(OtherTypeArgument);
52-
public object Attribute2Parameter2Value = "OtherArgument";
53-
public object Attribute2Parameter3Value = 2;
54-
55-
public string Attribute2NamedParameter1Name = "OtherNamedParameter1";
56-
public object Attribute2NamedParameter1Value = "OtherNamedArgument";
57-
public (string, object) Attribute2NamedParameter1Pair = (
58-
"OtherNamedParameter1",
59-
"OtherNamedArgument"
60-
);
61-
public string Attribute2NamedParameter2Name = "OtherNamedParameter2";
62-
public object Attribute2NamedParameter2Value = 3;
63-
public (string, object) Attribute2NamedParameter2Pair = ("OtherNamedParameter2", 3);
64-
public string Attribute2NamedParameter3Name = "OtherNamedParameter3";
65-
public object Attribute2NamedParameter3Value = typeof(OtherNamedTypeArgument);
66-
public (string, object) Attribute2NamedParameter3Pair = (
67-
"OtherNamedParameter3",
68-
typeof(OtherNamedTypeArgument)
69-
);
70-
71-
public string UnusedParameterName = "UnusedParameter";
72-
public object UnusedParameterValue = "UnusedValueArgument";
73-
public object UnusedTypeParameterValue = typeof(UnusedTypeArgument);
11+
public sealed override Architecture Architecture =>
12+
StaticTestArchitectures.AttributeArchitecture;
7413

7514
public Attribute Attribute1;
7615
public System.Type Attribute1SystemType = typeof(Attribute1);
7716

7817
public Attribute Attribute2;
7918
public System.Type Attribute2SystemType = typeof(Attribute2);
8019

20+
public Attribute Attribute3;
21+
public System.Type Attribute3SystemType = typeof(Attribute3);
22+
23+
public Attribute OnceUsedAttribute;
24+
public System.Type OnceUsedAttributeSystemType = typeof(OnceUsedAttribute);
25+
8126
public Attribute UnusedAttribute;
8227
public System.Type UnusedAttributeSystemType = typeof(UnusedAttribute);
8328

8429
public Class ClassWithoutAttributes;
8530
public System.Type ClassWithoutAttributesSystemType = typeof(ClassWithoutAttributes);
8631

87-
public Class OtherClassWithoutAttributes;
88-
public System.Type OtherClassWithoutAttributesSystemType = typeof(OtherClassWithoutAttributes);
89-
9032
public Class ClassWithSingleAttribute;
9133
public System.Type ClassWithSingleAttributeSystemType = typeof(ClassWithSingleAttribute);
9234

93-
public Class OtherClassWithSingleAttribute;
94-
public System.Type OtherClassWithSingleAttributeSystemType =
95-
typeof(OtherClassWithSingleAttribute);
35+
public Class ClassWithSingleUniquelyUsedAttribute;
36+
public System.Type ClassWithSingleUniquelyUsedAttributeSystemType =
37+
typeof(ClassWithSingleUniquelyUsedAttribute);
38+
39+
public Class ClassWithTwoAttributes;
40+
public System.Type ClassWithTwoAttributesSystemType = typeof(ClassWithTwoAttributes);
41+
42+
public Class ClassWithThreeAttributes;
43+
public System.Type ClassWithThreeAttributesSystemType = typeof(ClassWithThreeAttributes);
44+
45+
public readonly string UnusedAttributeStringValue = "NotTheValueOfAnyAttribute";
46+
public readonly int UnusedAttributeIntValue = 42;
47+
public readonly Class UnusedTypeArgument;
48+
public readonly System.Type UnusedTypeArgumentSystemType = typeof(UnusedTypeArgument);
49+
50+
public readonly object Attribute1StringArgument = "Argument1";
51+
public readonly object Attribute1IntegerArgument = 1;
52+
public readonly object Attribute1TypeArgument;
53+
public readonly object Attribute1TypeArgumentSystemType = typeof(TypeArgument1);
54+
55+
public readonly object Attribute2StringArgument = "Argument2";
56+
public readonly object Attribute2IntegerArgument = 2;
57+
public readonly object Attribute2TypeArgument;
58+
public readonly object Attribute2TypeArgumentSystemType = typeof(TypeArgument2);
9659

97-
public Class ClassWithAttributes;
98-
public System.Type ClassWithAttributesSystemType = typeof(ClassWithAttributes);
60+
public readonly object Attribute3StringArgument = "Argument3";
61+
public readonly object Attribute3IntegerArgument = 3;
62+
public readonly object Attribute3TypeArgument;
63+
public readonly object Attribute3TypeArgumentSystemType = typeof(TypeArgument3);
9964

100-
public Class OtherClassWithAttributes;
101-
public System.Type OtherClassWithAttributesSystemType = typeof(OtherClassWithAttributes);
65+
public Class ClassWithSingleAttributeWithArguments;
66+
public System.Type ClassWithSingleAttributeWithArgumentsSystemType =
67+
typeof(ClassWithSingleAttributeWithArguments);
10268

103-
public Class ClassWithArguments;
104-
public System.Type ClassWithArgumentsSystemType = typeof(ClassWithArguments);
69+
public Class ClassWithTwoAttributesWithArguments;
70+
public System.Type ClassWithTwoAttributesWithArgumentsSystemType =
71+
typeof(ClassWithTwoAttributesWithArguments);
10572

106-
public Class OtherClassWithArguments;
107-
public System.Type OtherClassWithArgumentsSystemType = typeof(OtherClassWithArguments);
73+
public Class ClassWithThreeAttributesWithArguments;
74+
public System.Type ClassWithThreeAttributesWithArgumentsSystemType =
75+
typeof(ClassWithThreeAttributesWithArguments);
76+
77+
public Class ClassWithSingleAttributeWithNamedArguments;
78+
public System.Type ClassWithSingleAttributeWithNamedArgumentsSystemType =
79+
typeof(ClassWithSingleAttributeWithNamedArguments);
80+
81+
public Class ClassWithTwoAttributesWithNamedArguments;
82+
public System.Type ClassWithTwoAttributesWithNamedArgumentsSystemType =
83+
typeof(ClassWithTwoAttributesWithNamedArguments);
84+
85+
public Class ClassWithThreeAttributesWithNamedArguments;
86+
public System.Type ClassWithThreeAttributesWithNamedArgumentsSystemType =
87+
typeof(ClassWithThreeAttributesWithNamedArguments);
10888

10989
public AttributeAssemblyTestHelpers()
11090
{
11191
Attribute1 = Architecture.GetAttributeOfType(typeof(Attribute1));
11292
Attribute2 = Architecture.GetAttributeOfType(typeof(Attribute2));
93+
Attribute3 = Architecture.GetAttributeOfType(typeof(Attribute3));
94+
OnceUsedAttribute = Architecture.GetAttributeOfType(typeof(OnceUsedAttribute));
11395
UnusedAttribute = Architecture.GetAttributeOfType(typeof(UnusedAttribute));
11496
ClassWithoutAttributes = Architecture.GetClassOfType(typeof(ClassWithoutAttributes));
115-
OtherClassWithoutAttributes = Architecture.GetClassOfType(
116-
typeof(OtherClassWithoutAttributes)
117-
);
11897
ClassWithSingleAttribute = Architecture.GetClassOfType(typeof(ClassWithSingleAttribute));
119-
OtherClassWithSingleAttribute = Architecture.GetClassOfType(
120-
typeof(OtherClassWithSingleAttribute)
98+
ClassWithSingleUniquelyUsedAttribute = Architecture.GetClassOfType(
99+
typeof(ClassWithSingleUniquelyUsedAttribute)
100+
);
101+
ClassWithTwoAttributes = Architecture.GetClassOfType(typeof(ClassWithTwoAttributes));
102+
ClassWithThreeAttributes = Architecture.GetClassOfType(typeof(ClassWithThreeAttributes));
103+
UnusedTypeArgument = Architecture.GetClassOfType(typeof(UnusedTypeArgument));
104+
Attribute1TypeArgument = Architecture.GetClassOfType(typeof(TypeArgument1));
105+
Attribute2TypeArgument = Architecture.GetClassOfType(typeof(TypeArgument2));
106+
Attribute3TypeArgument = Architecture.GetClassOfType(typeof(TypeArgument3));
107+
ClassWithSingleAttributeWithArguments = Architecture.GetClassOfType(
108+
typeof(ClassWithSingleAttributeWithArguments)
109+
);
110+
ClassWithTwoAttributesWithArguments = Architecture.GetClassOfType(
111+
typeof(ClassWithTwoAttributesWithArguments)
112+
);
113+
ClassWithThreeAttributesWithArguments = Architecture.GetClassOfType(
114+
typeof(ClassWithThreeAttributesWithArguments)
115+
);
116+
ClassWithSingleAttributeWithNamedArguments = Architecture.GetClassOfType(
117+
typeof(ClassWithSingleAttributeWithNamedArguments)
118+
);
119+
ClassWithTwoAttributesWithNamedArguments = Architecture.GetClassOfType(
120+
typeof(ClassWithTwoAttributesWithNamedArguments)
121+
);
122+
ClassWithThreeAttributesWithNamedArguments = Architecture.GetClassOfType(
123+
typeof(ClassWithThreeAttributesWithNamedArguments)
121124
);
122-
ClassWithAttributes = Architecture.GetClassOfType(typeof(ClassWithAttributes));
123-
OtherClassWithAttributes = Architecture.GetClassOfType(typeof(OtherClassWithAttributes));
124-
ClassWithArguments = Architecture.GetClassOfType(typeof(ClassWithArguments));
125-
OtherClassWithArguments = Architecture.GetClassOfType(typeof(OtherClassWithArguments));
126125
}
127126
}

ArchUnitNETTests/AssemblyTestHelper/DependencyAssemblyTestHelpers.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ namespace ArchUnitNETTests.AssemblyTestHelper;
88

99
public class DependencyAssemblyTestHelper : AssemblyTestHelper
1010
{
11-
public override Architecture Architecture
12-
{
13-
get => StaticTestArchitectures.DependencyArchitecture;
14-
}
11+
public sealed override Architecture Architecture =>
12+
StaticTestArchitectures.DependencyArchitecture;
1513

1614
public Class BaseClass;
1715
public Type BaseClassSystemType = typeof(BaseClass);

ArchUnitNETTests/AssemblyTestHelper/VisibilityAssemblyTestHelper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ namespace ArchUnitNETTests.AssemblyTestHelper;
99

1010
public class VisibilityAssemblyTestHelper : AssemblyTestHelper
1111
{
12-
public override Architecture Architecture
13-
{
14-
get => StaticTestArchitectures.VisibilityArchitecture;
15-
}
12+
public sealed override Architecture Architecture =>
13+
StaticTestArchitectures.VisibilityArchitecture;
1614

1715
public Class PublicClass;
1816
public Type PublicSystemType = typeof(PublicClass);

0 commit comments

Comments
 (0)