Skip to content

Commit 12a8d64

Browse files
Fix ImplementAny Failure Description
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
1 parent fd5fae5 commit 12a8d64

2 files changed

Lines changed: 50 additions & 54 deletions

File tree

ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -644,26 +644,22 @@ Architecture architecture
644644
)
645645
{
646646
var interfaceList = interfaces.GetObjects(architecture).ToList();
647-
var ruleTypeList = ruleTypes.ToList();
648-
var passedObjects = ruleTypeList
649-
.Where(type =>
650-
interfaceList.Count > 0
651-
? type.ImplementedInterfaces.Intersect(interfaceList).Any()
652-
: type.ImplementedInterfaces.Any()
653-
)
654-
.ToList();
655-
var failDescription =
656-
interfaceList.Count == 0
657-
? "does not implement any interface"
658-
: "only implements "
659-
+ string.Join(" and ", interfaceList.Select(i => i.FullName));
660-
foreach (var failedObject in ruleTypeList.Except(passedObjects))
661-
{
662-
yield return new ConditionResult(failedObject, false, failDescription);
663-
}
664-
foreach (var passedObject in passedObjects)
665-
{
666-
yield return new ConditionResult(passedObject, true);
647+
foreach (var ruleType in ruleTypes) {
648+
if (interfaceList.Count > 0
649+
? ruleType.ImplementedInterfaces.Intersect(interfaceList).Any()
650+
: ruleType.ImplementedInterfaces.Any())
651+
{
652+
yield return new ConditionResult(ruleType, true);
653+
}
654+
else
655+
{
656+
var failDescription =
657+
!ruleType.ImplementedInterfaces.Any()
658+
? "does not implement any interface"
659+
: "only implements "
660+
+ string.Join(" and ", ruleType.ImplementedInterfaces.Select(i => i.FullName));
661+
yield return new ConditionResult(ruleType, false, failDescription);
662+
}
667663
}
668664
}
669665

ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.ImplementAnyTest.verified.txt

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -110,46 +110,46 @@ All Evaluations passed
110110

111111
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"
112112
Result: False
113-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
113+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
114114
Message:
115115
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"" failed:
116-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
116+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
117117

118118

119119

120120
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"
121121
Result: False
122-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
122+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
123123
Message:
124124
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"" failed:
125-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
125+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
126126

127127

128128

129129
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"
130130
Result: False
131-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
131+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
132132
Message:
133133
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"" failed:
134-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
134+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
135135

136136

137137

138138
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"
139139
Result: False
140-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
140+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
141141
Message:
142142
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement "InterfaceAssembly.IOtherBaseInterface"" failed:
143-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
143+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
144144

145145

146146

147147
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any Interfaces that are "InterfaceAssembly.IOtherBaseInterface"
148148
Result: False
149-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
149+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
150150
Message:
151151
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any Interfaces that are "InterfaceAssembly.IOtherBaseInterface"" failed:
152-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
152+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
153153

154154

155155

@@ -251,10 +251,10 @@ Message:
251251

252252
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface"
253253
Result: False
254-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
254+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
255255
Message:
256256
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface"" failed:
257-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface
257+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
258258

259259

260260

@@ -464,46 +464,46 @@ Message:
464464

465465
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
466466
Result: False
467-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
467+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
468468
Message:
469469
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
470-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
470+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
471471

472472

473473

474474
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
475475
Result: False
476-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
476+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
477477
Message:
478478
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
479-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
479+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
480480

481481

482482

483483
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
484484
Result: False
485-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
485+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
486486
Message:
487487
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
488-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
488+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
489489

490490

491491

492492
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
493493
Result: False
494-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
494+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
495495
Message:
496496
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
497-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
497+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
498498

499499

500500

501501
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any Interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
502502
Result: False
503-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
503+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
504504
Message:
505505
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any Interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
506-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
506+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
507507

508508

509509

@@ -605,57 +605,57 @@ Message:
605605

606606
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
607607
Result: False
608-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
608+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
609609
Message:
610610
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
611-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
611+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
612612

613613

614614

615615
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
616616
Result: False
617-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
617+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
618618
Message:
619619
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
620-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
620+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
621621

622622

623623

624624
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
625625
Result: False
626-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
626+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
627627
Message:
628628
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
629-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
629+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
630630

631631

632632

633633
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
634634
Result: False
635-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
635+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
636636
Message:
637637
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
638-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
638+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
639639

640640

641641

642642
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are Interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
643643
Result: False
644-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
644+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
645645
Message:
646646
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are Interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
647-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
647+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
648648

649649

650650

651651
----- Complex conditions -----
652652

653653
Query: Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"
654654
Result: False
655-
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
655+
Description: InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
656656
Message:
657657
"Interfaces that are "InterfaceAssembly.IChildInterface" should implement any interfaces that are "InterfaceAssembly.IOtherBaseInterface" or "InterfaceAssembly.IOtherChildInterface"" failed:
658-
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IOtherBaseInterface and InterfaceAssembly.IOtherChildInterface
658+
InterfaceAssembly.IChildInterface only implements InterfaceAssembly.IBaseInterface
659659

660660

661661

0 commit comments

Comments
 (0)