From 88963310540b6e95f6d2eb94784feb479e2c382b Mon Sep 17 00:00:00 2001 From: Alexander Linne Date: Fri, 13 Feb 2026 11:52:37 +0100 Subject: [PATCH] Correct behavior of ImplementAny fluent syntax for empty arguments Signed-off-by: Alexander Linne --- .../Types/TypeConditionsDefinition.cs | 17 +- .../Types/TypePredicatesDefinition.cs | 13 +- ...ts.ImplementAnyInterfacesTest.verified.txt | 192 +++++++----------- ...NotImplementAnyInterfacesTest.verified.txt | 179 ++++------------ .../Elements/TypeSyntaxElementsTests.cs | 56 +---- 5 files changed, 128 insertions(+), 329 deletions(-) diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs index bb1d5d595..f6313f985 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs @@ -570,9 +570,7 @@ Architecture architecture foreach (var ruleType in ruleTypes) { if ( - interfaceList.Count > 0 - ? ruleType.ImplementedInterfaces.Intersect(interfaceList).Any() - : ruleType.ImplementedInterfaces.Any() + interfaceList.Count > 0 && ruleType.ImplementedInterfaces.Intersect(interfaceList).Any() ) { yield return new ConditionResult(ruleType, true); @@ -592,7 +590,7 @@ Architecture architecture } var description = interfaces.FormatDescription( - "implement any interface", + "implement any of no interfaces (always false)", "implement", "implement any" ); @@ -1211,11 +1209,10 @@ Architecture architecture var interfaceList = interfaces.GetObjects(architecture).ToList(); foreach (var ruleType in ruleTypes.ToList()) { - var matchingInterfaces = - interfaceList.Count > 0 - ? ruleType.ImplementedInterfaces.Intersect(interfaceList).ToList() - : ruleType.ImplementedInterfaces.ToList(); - if (matchingInterfaces.Any()) + var matchingInterfaces = ruleType.ImplementedInterfaces.Intersect( + interfaceList + ); + if (interfaceList.Count > 0 && matchingInterfaces.Any()) { yield return new ConditionResult( ruleType, @@ -1232,7 +1229,7 @@ Architecture architecture } var description = interfaces.FormatDescription( - "not implement any interface", + "not implement any of no interfaces (always true)", "not implement", "not implement any" ); diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs index 3244b7f6d..c05b5574b 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypePredicatesDefinition.cs @@ -347,13 +347,11 @@ IEnumerable Condition(IEnumerable ruleTypes, Architecture architecture) { var interfaceList = interfaces.GetObjects(architecture).ToList(); return ruleTypes.Where(type => - interfaceList.Count > 0 - ? type.ImplementedInterfaces.Intersect(interfaceList).Any() - : type.ImplementedInterfaces.Any() + interfaceList.Count > 0 && type.ImplementedInterfaces.Intersect(interfaceList).Any() ); } var description = interfaces.FormatDescription( - "implement any interface", + "implement any of no interfaces (always false)", "implement", "implement any" ); @@ -695,13 +693,12 @@ IEnumerable Condition(IEnumerable ruleTypes, Architecture architecture) { var interfaceList = interfaces.GetObjects(architecture).ToList(); return ruleTypes.Where(type => - interfaceList.Count > 0 - ? !type.ImplementedInterfaces.Intersect(interfaceList).Any() - : !type.ImplementedInterfaces.Any() + interfaceList.Count <= 0 + || !type.ImplementedInterfaces.Intersect(interfaceList).Any() ); } var description = interfaces.FormatDescription( - "do not implement any interface", + "do not implement any of no interfaces (always true)", "do not implement", "do not implement any" ); diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.ImplementAnyInterfacesTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.ImplementAnyInterfacesTest.verified.txt index e10ffdf37..bb85ad741 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.ImplementAnyInterfacesTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.ImplementAnyInterfacesTest.verified.txt @@ -258,203 +258,157 @@ Message: -===== Empty Arguments (No Violations) ===== +===== Empty Arguments (Only Violations) ===== ----- Conditions ----- -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any Interfaces that have name "NotTheNameOfAnyObject" -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - ------ Predicates ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - ------ Predicates as conditions ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that implement any interface -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that implement any Interfaces that have name "NotTheNameOfAnyObject" -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - ------ Complex conditions ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are any of no objects (always empty) -Result: True -Description: InterfaceAssembly.IChildInterface passed -Message: -All Evaluations passed - -===== Empty Arguments (Violations) ===== - ------ Conditions ----- - -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any of no interfaces (always false) Result: False Description: InterfaceAssembly.IBaseInterface does not implement any interface +Result: False +Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interface" failed: +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any of no interfaces (always false)" failed: InterfaceAssembly.IBaseInterface does not implement any interface + InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any of no interfaces (always false) Result: False Description: InterfaceAssembly.IBaseInterface does not implement any interface +Result: False +Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interface" failed: +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any of no interfaces (always false)" failed: InterfaceAssembly.IBaseInterface does not implement any interface + InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any of no interfaces (always false) Result: False Description: InterfaceAssembly.IBaseInterface does not implement any interface +Result: False +Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interface" failed: +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any of no interfaces (always false)" failed: InterfaceAssembly.IBaseInterface does not implement any interface + InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any Interfaces that have name "NotTheNameOfAnyObject" +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any Interfaces that have name "NotTheNameOfAnyObject" Result: False Description: InterfaceAssembly.IBaseInterface does not implement any interface +Result: False +Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: InterfaceAssembly.IBaseInterface does not implement any interface + InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface ----- Predicates ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any of no interfaces (always false) +Result: False +Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any of no interfaces (always false) Result: False -Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any interface +Description: InterfaceAssembly.IChildInterface is not Interfaces that implement any of no interfaces (always false) Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any interface" failed: - InterfaceAssembly.IBaseInterface is not Interfaces that implement any interface +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any of no interfaces (always false)" failed: + InterfaceAssembly.IBaseInterface is not Interfaces that implement any of no interfaces (always false) + InterfaceAssembly.IChildInterface is not Interfaces that implement any of no interfaces (always false) -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any of no interfaces (always false) +Result: False +Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any of no interfaces (always false) Result: False -Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any interface +Description: InterfaceAssembly.IChildInterface is not Interfaces that implement any of no interfaces (always false) Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any interface" failed: - InterfaceAssembly.IBaseInterface is not Interfaces that implement any interface +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any of no interfaces (always false)" failed: + InterfaceAssembly.IBaseInterface is not Interfaces that implement any of no interfaces (always false) + InterfaceAssembly.IChildInterface is not Interfaces that implement any of no interfaces (always false) -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any of no interfaces (always false) Result: False -Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any interface +Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any of no interfaces (always false) +Result: False +Description: InterfaceAssembly.IChildInterface is not Interfaces that implement any of no interfaces (always false) Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any interface" failed: - InterfaceAssembly.IBaseInterface is not Interfaces that implement any interface +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any of no interfaces (always false)" failed: + InterfaceAssembly.IBaseInterface is not Interfaces that implement any of no interfaces (always false) + InterfaceAssembly.IChildInterface is not Interfaces that implement any of no interfaces (always false) -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" Result: False Description: InterfaceAssembly.IBaseInterface is not Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" +Result: False +Description: InterfaceAssembly.IChildInterface is not Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: InterfaceAssembly.IBaseInterface is not Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" + InterfaceAssembly.IChildInterface is not Interfaces that implement any Interfaces that have name "NotTheNameOfAnyObject" ----- Predicates as conditions ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that implement any of no interfaces (always false) +Result: False +Description: InterfaceAssembly.IBaseInterface does exist Result: False -Description: InterfaceAssembly.IBaseInterface is not "InterfaceAssembly.IChildInterface" or "InterfaceAssembly.IOtherChildInterface" or "InterfaceAssembly.IInterfaceWithMultipleDependencies" +Description: InterfaceAssembly.IChildInterface does exist Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that implement any interface" failed: - InterfaceAssembly.IBaseInterface is not "InterfaceAssembly.IChildInterface" or "InterfaceAssembly.IOtherChildInterface" or "InterfaceAssembly.IInterfaceWithMultipleDependencies" +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that implement any of no interfaces (always false)" failed: + InterfaceAssembly.IBaseInterface does exist + InterfaceAssembly.IChildInterface does exist -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that implement any of no interfaces (always false) Result: False -Description: InterfaceAssembly.IBaseInterface is not "InterfaceAssembly.IChildInterface" or "InterfaceAssembly.IOtherChildInterface" or "InterfaceAssembly.IInterfaceWithMultipleDependencies" +Description: InterfaceAssembly.IBaseInterface does exist +Result: False +Description: InterfaceAssembly.IChildInterface does exist Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that implement any interface" failed: - InterfaceAssembly.IBaseInterface is not "InterfaceAssembly.IChildInterface" or "InterfaceAssembly.IOtherChildInterface" or "InterfaceAssembly.IInterfaceWithMultipleDependencies" +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that implement any of no interfaces (always false)" failed: + InterfaceAssembly.IBaseInterface does exist + InterfaceAssembly.IChildInterface does exist -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that implement any Interfaces that have name "NotTheNameOfAnyObject" +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that implement any Interfaces that have name "NotTheNameOfAnyObject" +Result: False +Description: InterfaceAssembly.IBaseInterface does exist Result: False -Description: InterfaceAssembly.IBaseInterface is not "InterfaceAssembly.IChildInterface" or "InterfaceAssembly.IOtherChildInterface" or "InterfaceAssembly.IInterfaceWithMultipleDependencies" +Description: InterfaceAssembly.IChildInterface does exist Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: - InterfaceAssembly.IBaseInterface is not "InterfaceAssembly.IChildInterface" or "InterfaceAssembly.IOtherChildInterface" or "InterfaceAssembly.IInterfaceWithMultipleDependencies" +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: + InterfaceAssembly.IBaseInterface does exist + InterfaceAssembly.IChildInterface does exist ----- Complex conditions ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interfaces that are any of no objects (always empty) +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any interfaces that are any of no objects (always empty) Result: False Description: InterfaceAssembly.IBaseInterface does not implement any interface +Result: False +Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface Message: -"Interfaces that are "InterfaceAssembly.IBaseInterface" should implement any interfaces that are any of no objects (always empty)" failed: +"Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should implement any interfaces that are any of no objects (always empty)" failed: InterfaceAssembly.IBaseInterface does not implement any interface + InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.NotImplementAnyInterfacesTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.NotImplementAnyInterfacesTest.verified.txt index cd468f61a..63d706e82 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.NotImplementAnyInterfacesTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.NotImplementAnyInterfacesTest.verified.txt @@ -262,217 +262,116 @@ Message: ----- Conditions ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should not implement any Interfaces that have name "NotTheNameOfAnyObject" +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should not implement any Interfaces that have name "NotTheNameOfAnyObject" Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed ----- Predicates ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that do not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that do not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that do not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be Interfaces that do not implement any Interfaces that have name "NotTheNameOfAnyObject" +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any Interfaces that have name "NotTheNameOfAnyObject" Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed ----- Predicates as conditions ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that do not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that do not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that do not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that do not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that do not implement any interface +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that do not implement any of no interfaces (always true) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should be types that do not implement any Interfaces that have name "NotTheNameOfAnyObject" +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should be types that do not implement any Interfaces that have name "NotTheNameOfAnyObject" Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed ----- Complex conditions ----- -Query: Interfaces that are "InterfaceAssembly.IBaseInterface" should not implement any interfaces that are any of no objects (always empty) +Query: Interfaces that are "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IChildInterface" should not implement any interfaces that are any of no objects (always empty) Result: True Description: InterfaceAssembly.IBaseInterface passed +Result: True +Description: InterfaceAssembly.IChildInterface passed Message: All Evaluations passed -===== Empty Arguments (Violations) ===== - ------ Conditions ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interface" failed: - InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interface" failed: - InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interface" failed: - InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any Interfaces that have name "NotTheNameOfAnyObject" -Result: False -Description: InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: - InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface - - - ------ Predicates ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface is not Interfaces that do not implement any interface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any interface" failed: - InterfaceAssembly.IChildInterface is not Interfaces that do not implement any interface - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface is not Interfaces that do not implement any interface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any interface" failed: - InterfaceAssembly.IChildInterface is not Interfaces that do not implement any interface - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface is not Interfaces that do not implement any interface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any interface" failed: - InterfaceAssembly.IChildInterface is not Interfaces that do not implement any interface - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any Interfaces that have name "NotTheNameOfAnyObject" -Result: False -Description: InterfaceAssembly.IChildInterface is not Interfaces that do not implement any Interfaces that have name "NotTheNameOfAnyObject" -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be Interfaces that do not implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: - InterfaceAssembly.IChildInterface is not Interfaces that do not implement any Interfaces that have name "NotTheNameOfAnyObject" - - - ------ Predicates as conditions ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any interface" failed: - InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any interface" failed: - InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any interface -Result: False -Description: InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any interface" failed: - InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" - - - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any Interfaces that have name "NotTheNameOfAnyObject" -Result: False -Description: InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should be types that do not implement any Interfaces that have name "NotTheNameOfAnyObject"" failed: - InterfaceAssembly.IChildInterface is not "InterfaceAssembly.IBaseInterface" or "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IInterfaceWithoutDependencies" or "System.Runtime.CompilerServices.CompilationRelaxationsAttribute" or "System.Int32" or "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" or "System.Boolean" or "System.Diagnostics.DebuggableAttribute" or "System.Diagnostics.DebuggableAttribute+DebuggingModes" or "System.Runtime.Versioning.TargetFrameworkAttribute" or "System.String" or "System.Reflection.AssemblyCompanyAttribute" or "System.Reflection.AssemblyConfigurationAttribute" or "System.Reflection.AssemblyFileVersionAttribute" or "System.Reflection.AssemblyInformationalVersionAttribute" or "System.Reflection.AssemblyProductAttribute" or "System.Reflection.AssemblyTitleAttribute" - - - ------ Complex conditions ----- - -Query: Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interfaces that are any of no objects (always empty) -Result: False -Description: InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface -Message: -"Interfaces that are "InterfaceAssembly.IChildInterface" should not implement any interfaces that are any of no objects (always empty)" failed: - InterfaceAssembly.IChildInterface does implement InterfaceAssembly.IBaseInterface - - - ===== Multiple arguments ===== ----- Conditions ----- diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs index b941bba42..fbc3499b6 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs @@ -720,39 +720,15 @@ public async Task ImplementAnyInterfacesTest() helper.AddSnapshotSubHeader("Complex conditions"); should.ImplementAnyInterfacesThat().Are(helper.OtherBaseInterface).AssertOnlyViolations(helper); - helper.AddSnapshotHeader("Empty Arguments (No Violations)"); - should = Interfaces().That().Are(helper.ChildInterface).Should(); - - helper.AddSnapshotSubHeader("Conditions"); - should.ImplementAnyInterfaces().AssertNoViolations(helper); - should.ImplementAnyInterfaces(new List()).AssertNoViolations(helper); - should.ImplementAnyInterfaces(new List()).AssertNoViolations(helper); - should.ImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName)).AssertNoViolations(helper); - - helper.AddSnapshotSubHeader("Predicates"); - should.Be(Interfaces().That().ImplementAnyInterfaces()).AssertNoViolations(helper); - should.Be(Interfaces().That().ImplementAnyInterfaces(new List())).AssertNoViolations(helper); - should.Be(Interfaces().That().ImplementAnyInterfaces(new List())).AssertNoViolations(helper); - should.Be(Interfaces().That().ImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName))).AssertNoViolations(helper); - - helper.AddSnapshotSubHeader("Predicates as conditions"); - should.BeTypesThat().ImplementAnyInterfaces(); - should.BeTypesThat().ImplementAnyInterfaces(new List()).AssertNoViolations(helper); - should.BeTypesThat().ImplementAnyInterfaces(new List()).AssertNoViolations(helper); - should.BeTypesThat().ImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName)).AssertNoViolations(helper); - - helper.AddSnapshotSubHeader("Complex conditions"); - should.ImplementAnyInterfacesThat().Are(new List()).AssertNoViolations(helper); - - helper.AddSnapshotHeader("Empty Arguments (Violations)"); - should = Interfaces().That().Are(helper.BaseInterface).Should(); + helper.AddSnapshotHeader("Empty Arguments (Only Violations)"); + should = Interfaces().That().Are(helper.BaseInterface, helper.ChildInterface).Should(); helper.AddSnapshotSubHeader("Conditions"); should.ImplementAnyInterfaces().AssertOnlyViolations(helper); should.ImplementAnyInterfaces(new List()).AssertOnlyViolations(helper); should.ImplementAnyInterfaces(new List()).AssertOnlyViolations(helper); should.ImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName)).AssertOnlyViolations(helper); - + helper.AddSnapshotSubHeader("Predicates"); should.Be(Interfaces().That().ImplementAnyInterfaces()).AssertOnlyViolations(helper); should.Be(Interfaces().That().ImplementAnyInterfaces(new List())).AssertOnlyViolations(helper); @@ -865,7 +841,7 @@ public async Task NotImplementAnyInterfacesTest() should.NotImplementAnyInterfacesThat().Are(helper.BaseInterface).AssertOnlyViolations(helper); helper.AddSnapshotHeader("Empty Arguments (No Violations)"); - should = Interfaces().That().Are(helper.BaseInterface).Should(); + should = Interfaces().That().Are(helper.BaseInterface, helper.ChildInterface).Should(); helper.AddSnapshotSubHeader("Conditions"); should.NotImplementAnyInterfaces().AssertNoViolations(helper); @@ -888,30 +864,6 @@ public async Task NotImplementAnyInterfacesTest() helper.AddSnapshotSubHeader("Complex conditions"); should.NotImplementAnyInterfacesThat().Are(new List()).AssertNoViolations(helper); - helper.AddSnapshotHeader("Empty Arguments (Violations)"); - should = Interfaces().That().Are(helper.ChildInterface).Should(); - - helper.AddSnapshotSubHeader("Conditions"); - should.NotImplementAnyInterfaces().AssertOnlyViolations(helper); - should.NotImplementAnyInterfaces(new List()).AssertOnlyViolations(helper); - should.NotImplementAnyInterfaces(new List()).AssertOnlyViolations(helper); - should.NotImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName)).AssertOnlyViolations(helper); - - helper.AddSnapshotSubHeader("Predicates"); - should.Be(Interfaces().That().DoNotImplementAnyInterfaces()).AssertOnlyViolations(helper); - should.Be(Interfaces().That().DoNotImplementAnyInterfaces(new List())).AssertOnlyViolations(helper); - should.Be(Interfaces().That().DoNotImplementAnyInterfaces(new List())).AssertOnlyViolations(helper); - should.Be(Interfaces().That().DoNotImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName))).AssertOnlyViolations(helper); - - helper.AddSnapshotSubHeader("Predicates as conditions"); - should.BeTypesThat().DoNotImplementAnyInterfaces().AssertOnlyViolations(helper); - should.BeTypesThat().DoNotImplementAnyInterfaces(new List()).AssertOnlyViolations(helper); - should.BeTypesThat().DoNotImplementAnyInterfaces(new List()).AssertOnlyViolations(helper); - should.BeTypesThat().DoNotImplementAnyInterfaces(Interfaces().That().HaveName(helper.NonExistentObjectName)).AssertOnlyViolations(helper); - - helper.AddSnapshotSubHeader("Complex conditions"); - should.NotImplementAnyInterfacesThat().Are(new List()).AssertOnlyViolations(helper); - helper.AddSnapshotHeader("Multiple arguments"); should = Interfaces().That().Are(helper.ChildInterface).Should();