Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ list_license.ps1
*.user

# Visual Studio cache/options directory
.vs/
.vs/

# Test Results and Coverage Reports
TestResults/
coveragereport/
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ namespace ArchUnitNET.Fluent.Syntax.Elements.Members.MethodMembers
{
public static class MethodMemberConditionsDefinition
{
public static RelationCondition<MethodMember, MethodMember> BeMethodMembersThat()
{
return new RelationCondition<MethodMember, MethodMember>(
ObjectConditionsDefinition<MethodMember>.Be,
"be method members that",
"are not method members that"
);
}

public static ICondition<MethodMember> BeConstructor()
{
return new SimpleCondition<MethodMember>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ public class MethodMembersShould
public MethodMembersShould(IArchRuleCreator<MethodMember> ruleCreator)
: base(ruleCreator) { }

public ShouldRelateToMethodMembersThat<
MethodMembersShouldConjunction,
MethodMember
> BeMethodMembersThat()
{
_ruleCreator.BeginComplexCondition(
ArchRuleDefinition.MethodMembers(),
MethodMemberConditionsDefinition.BeMethodMembersThat()
);
return new ShouldRelateToMethodMembersThat<
MethodMembersShouldConjunction,
MethodMember
>(_ruleCreator);
}

public MethodMembersShouldConjunction BeConstructor()
{
_ruleCreator.AddCondition(MethodMemberConditionsDefinition.BeConstructor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2939,7 +2939,7 @@ bool Condition(TRuleType obj, Architecture architecture)
return true;
}

return new ArchitectureCondition<TRuleType>(Condition, failDescription, description);
return new ArchitectureCondition<TRuleType>(Condition, description, failDescription);
}

public static ICondition<TRuleType> NotHaveAttributeWithNamedArguments(
Expand Down Expand Up @@ -3041,7 +3041,7 @@ bool Condition(TRuleType obj, Architecture architecture)
return true;
}

return new ArchitectureCondition<TRuleType>(Condition, failDescription, description);
return new ArchitectureCondition<TRuleType>(Condition, description, failDescription);
}

[Obsolete(
Expand Down
16 changes: 9 additions & 7 deletions ArchUnitNET/Fluent/Syntax/Elements/ObjectPredicatesDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ bool Condition(T obj, Architecture architecture)
goto NextAttribute;
}
}
else if (!argumentList.Contains(arg))
else if (!attributeArgs.Contains(arg))
{
goto NextAttribute;
}
Expand Down Expand Up @@ -1527,7 +1527,7 @@ bool Predicate(T obj, Architecture architecture)
goto NextAttribute;
}
}
else if (!argumentList.Contains(arg))
else if (!attributeArgs.Contains(arg))
{
goto NextAttribute;
}
Expand Down Expand Up @@ -2344,7 +2344,9 @@ bool Predicate(T obj, Architecture architecture)
return false;
}
}
else if (attributeArguments.Contains(arg))
else if (
attributeArguments.Contains(arg) || typeAttributeArguments.Contains(arg)
)
{
return false;
}
Expand Down Expand Up @@ -2434,7 +2436,7 @@ IEnumerable<object> argumentValues
)
{
string description;
var argumentValueList = argumentValues?.ToList() ?? new List<object> { null };
var argumentValueList = argumentValues?.ToList() ?? new List<object> { };
if (argumentValueList.IsNullOrEmpty())
{
description = "do not have attribute \"" + attribute.FullName + "\"";
Expand Down Expand Up @@ -2503,7 +2505,7 @@ IEnumerable<object> argumentValues
)
{
string description;
var argumentValueList = argumentValues?.ToList() ?? new List<object> { null };
var argumentValueList = argumentValues?.ToList() ?? new List<object> { };
if (argumentValueList.IsNullOrEmpty())
{
description = "do not have attribute \"" + attribute.FullName + "\"";
Expand Down Expand Up @@ -2784,7 +2786,7 @@ bool Predicate(T obj, Architecture architecture)
goto NextAttribute;
}
}
else if (!argumentList.Contains(arg))
else if (!attributeArgs.Contains(arg))
{
goto NextAttribute;
}
Expand Down Expand Up @@ -2872,7 +2874,7 @@ bool Predicate(T obj, Architecture architecture)
goto NextAttribute;
}
}
else if (!argumentList.Contains(arg))
else if (!attributeArgs.Contains(arg))
{
goto NextAttribute;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ IEnumerable<object> argumentValues
)
{
_ruleCreator.ContinueComplexCondition(
ObjectPredicatesDefinition<TReferenceType>.DoNotHaveAnyAttributesWithArguments(
ObjectPredicatesDefinition<TReferenceType>.DoNotHaveAttributeWithArguments(
attribute,
argumentValues
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ bool Condition(TRuleType ruleType)
return new SimpleCondition<TRuleType>(Condition, description, failDescription);
}

public static RelationCondition<TRuleType, IType> BeTypesThat()
{
return new RelationCondition<TRuleType, IType>(
ObjectConditionsDefinition<TRuleType>.Be,
"be types that",
"are not types that"
);
}

public static ICondition<TRuleType> BeAssignableTo(
IType firstType,
params IType[] moreTypes
Expand Down
11 changes: 11 additions & 0 deletions ArchUnitNET/Fluent/Syntax/Elements/Types/TypesShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ public TRuleTypeShouldConjunction BeAssignableTo(
return Create<TRuleTypeShouldConjunction, TRuleType>(_ruleCreator);
}

public ShouldRelateToTypesThat<TRuleTypeShouldConjunction, IType, TRuleType> BeTypesThat()
{
_ruleCreator.BeginComplexCondition(
ArchRuleDefinition.Types(true),
TypeConditionsDefinition<TRuleType>.BeTypesThat()
);
return new ShouldRelateToTypesThat<TRuleTypeShouldConjunction, IType, TRuleType>(
_ruleCreator
);
}

public TRuleTypeShouldConjunction BeAssignableTo(IType firstType, params IType[] moreTypes)
{
_ruleCreator.AddCondition(
Expand Down
1 change: 1 addition & 0 deletions ArchUnitNETTests/ArchUnitNETTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Dependencies\cpplib\" />
<Folder Include="Fluent\Syntax\Elements\Snapshots\" />
</ItemGroup>
<ItemGroup>
<Reference Include="CppDllTest">
Expand Down
5 changes: 5 additions & 0 deletions ArchUnitNETTests/AssemblyTestHelper/AssemblyTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public void AddSnapshotHeader(string header)
snapshot.AppendLine("===== " + header + " =====\n");
}

public void AddSnapshotSubHeader(string subHeader)
{
snapshot.AppendLine("----- " + subHeader + " -----\n");
}

private string FormatSnapshot(IArchRule rule, IEnumerable<EvaluationResult> results)
{
var formatted = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public class DependencyAssemblyTestHelper : AssemblyTestHelper
public Class ClassWithoutDependencies;
public Type ClassWithoutDependenciesSystemType = typeof(ClassWithoutDependencies);

public Class GenericBaseClass;
public Type GenericBaseClassSystemType = typeof(GenericBaseClass<>);

public Class ChildClassOfGeneric;
public Type ChildClassOfGenericSystemType = typeof(ChildClassOfGeneric);

public Class OtherClassWithoutDependencies;
public Type OtherClassWithoutDependenciesSystemType = typeof(OtherClassWithoutDependencies);

Expand Down Expand Up @@ -84,6 +90,8 @@ public DependencyAssemblyTestHelper()
ClassWithMultipleDependencies = Architecture.GetClassOfType(
typeof(ClassWithMultipleDependencies)
);
GenericBaseClass = Architecture.GetClassOfType(typeof(GenericBaseClass<>));
ChildClassOfGeneric = Architecture.GetClassOfType(typeof(ChildClassOfGeneric));
ClassWithoutDependencies = Architecture.GetClassOfType(typeof(ClassWithoutDependencies));
OtherClassWithoutDependencies = Architecture.GetClassOfType(
typeof(OtherClassWithoutDependencies)
Expand Down
Loading
Loading