From ecbe09fc062ac9f5c3dfd677f1361cdf7d7c9bb6 Mon Sep 17 00:00:00 2001 From: Alexander Linne Date: Sat, 21 Mar 2026 00:10:59 +0100 Subject: [PATCH 1/2] test: rewrite method member syntax elements tests Signed-off-by: Alexander Linne --- .../MethodDependencyAssemblyTestHelper.cs | 24 + .../TypeAssemblyTestHelper.cs | 76 ++ .../MethodMemberSyntaxElementsTests.cs | 984 ++++++++++-------- ...xElementsTests.BeCalledByTest.verified.txt | 285 +++++ ...ementsTests.BeConstructorTest.verified.txt | 63 ++ ...Tests.BeMethodMembersThatTest.verified.txt | 19 + ...entsTests.BeNoConstructorTest.verified.txt | 63 ++ ...axElementsTests.BeVirtualTest.verified.txt | 63 ++ ...Tests.DoNotHaveReturnTypeTest.verified.txt | 247 +++++ ...eDependencyInMethodBodyToTest.verified.txt | 285 +++++ ...mentsTests.HaveReturnTypeTest.verified.txt | 237 +++++ ...ementsTests.NotBeCalledByTest.verified.txt | 273 +++++ ...lementsTests.NotBeVirtualTest.verified.txt | 63 ++ ...eDependencyInMethodBodyToTest.verified.txt | 273 +++++ .../MethodDependency.cs | 15 + TestAssemblies/TypeAssembly/Type.cs | 48 + 16 files changed, 2593 insertions(+), 425 deletions(-) create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeConstructorTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeNoConstructorTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeVirtualTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeVirtualTest.verified.txt create mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt diff --git a/ArchUnitNETTests/AssemblyTestHelper/MethodDependencyAssemblyTestHelper.cs b/ArchUnitNETTests/AssemblyTestHelper/MethodDependencyAssemblyTestHelper.cs index 99a5a9eae..368e88bed 100644 --- a/ArchUnitNETTests/AssemblyTestHelper/MethodDependencyAssemblyTestHelper.cs +++ b/ArchUnitNETTests/AssemblyTestHelper/MethodDependencyAssemblyTestHelper.cs @@ -9,6 +9,14 @@ public class MethodDependencyAssemblyTestHelper : AssemblyTestHelper public sealed override Architecture Architecture => StaticTestArchitectures.MethodDependencyArchitecture; + public Class MethodDependencyClass; + public System.Type MethodDependencyClassSystemType = + typeof(MethodDependencyNamespace.MethodDependencyClass); + + public Class OtherCallingClass; + public System.Type OtherCallingClassSystemType = + typeof(MethodDependencyNamespace.OtherCallingClass); + public MethodMember MethodWithSingleDependency; public MethodMember CalledMethod; @@ -23,8 +31,18 @@ public class MethodDependencyAssemblyTestHelper : AssemblyTestHelper public MethodMember MethodWithoutDependencies; + public MethodMember MethodCallingCalledMethod; + + public MethodMember AnotherMethodCallingCalledMethod; + public MethodDependencyAssemblyTestHelper() { + MethodDependencyClass = Architecture.GetClassOfType( + typeof(MethodDependencyNamespace.MethodDependencyClass) + ); + OtherCallingClass = Architecture.GetClassOfType( + typeof(MethodDependencyNamespace.OtherCallingClass) + ); MethodWithSingleDependency = Architecture .MethodMembers.WhereNameIs("MethodWithSingleDependency()") .First(); @@ -38,5 +56,11 @@ public MethodDependencyAssemblyTestHelper() MethodWithoutDependencies = Architecture .MethodMembers.WhereNameIs("MethodWithoutDependencies()") .First(); + MethodCallingCalledMethod = Architecture + .MethodMembers.WhereNameIs("MethodCallingCalledMethod()") + .First(); + AnotherMethodCallingCalledMethod = Architecture + .MethodMembers.WhereNameIs("AnotherMethodCallingCalledMethod()") + .First(); } } diff --git a/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs b/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs index 5576ed067..c65e2e497 100644 --- a/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs +++ b/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs @@ -142,6 +142,29 @@ public class TypeAssemblyTestHelper : AssemblyTestHelper public Class ClassWithStaticMethod; public Type ClassWithStaticMethodSystemType = typeof(ClassWithStaticMethod); + // Method member test classes + public Class ClassWithVirtualMethod; + public Type ClassWithVirtualMethodSystemType = typeof(ClassWithVirtualMethod); + + public Class OtherClassWithVirtualMethod; + public Type OtherClassWithVirtualMethodSystemType = typeof(OtherClassWithVirtualMethod); + + public Class ClassWithNonVirtualMethod; + public Type ClassWithNonVirtualMethodSystemType = typeof(ClassWithNonVirtualMethod); + + public Class ClassWithStringReturnType; + public Type ClassWithStringReturnTypeSystemType = typeof(ClassWithStringReturnType); + + public Class ClassWithIntReturnType; + public Type ClassWithIntReturnTypeSystemType = typeof(ClassWithIntReturnType); + + public Class ClassWithRegularClassReturnType; + public Type ClassWithRegularClassReturnTypeSystemType = typeof(ClassWithRegularClassReturnType); + + public Class ClassWithOtherRegularClassReturnType; + public Type ClassWithOtherRegularClassReturnTypeSystemType = + typeof(ClassWithOtherRegularClassReturnType); + // Individual members public IMember StaticField; public IMember NonStaticField; @@ -154,6 +177,17 @@ public class TypeAssemblyTestHelper : AssemblyTestHelper public IMember StaticProperty; public IMember StaticMethod; + // Method members (MethodMember type) + public MethodMember VirtualMethod; + public MethodMember OtherVirtualMethod; + public MethodMember NonVirtualMethod; + public MethodMember MethodReturningString; + public MethodMember MethodReturningInt; + public MethodMember ClassWithVirtualMethodConstructor; + public MethodMember ClassWithNonVirtualMethodConstructor; + public MethodMember MethodReturningRegularClass; + public MethodMember MethodReturningOtherRegularClass; + public TypeAssemblyTestHelper() { SimpleEnum = Architecture.GetITypeOfType(typeof(SimpleEnum)); @@ -241,5 +275,47 @@ public TypeAssemblyTestHelper() .GetPropertyMembersWithName("StaticProperty") .First(); StaticMethod = ClassWithStaticMethod.GetMethodMembersWithName("StaticMethod()").First(); + + // Method member test classes + ClassWithVirtualMethod = Architecture.GetClassOfType(typeof(ClassWithVirtualMethod)); + OtherClassWithVirtualMethod = Architecture.GetClassOfType( + typeof(OtherClassWithVirtualMethod) + ); + ClassWithNonVirtualMethod = Architecture.GetClassOfType(typeof(ClassWithNonVirtualMethod)); + ClassWithStringReturnType = Architecture.GetClassOfType(typeof(ClassWithStringReturnType)); + ClassWithIntReturnType = Architecture.GetClassOfType(typeof(ClassWithIntReturnType)); + ClassWithRegularClassReturnType = Architecture.GetClassOfType( + typeof(ClassWithRegularClassReturnType) + ); + ClassWithOtherRegularClassReturnType = Architecture.GetClassOfType( + typeof(ClassWithOtherRegularClassReturnType) + ); + + // Method members (MethodMember type) + VirtualMethod = ClassWithVirtualMethod.GetMethodMembersWithName("VirtualMethod()").First(); + OtherVirtualMethod = OtherClassWithVirtualMethod + .GetMethodMembersWithName("OtherVirtualMethod()") + .First(); + NonVirtualMethod = ClassWithNonVirtualMethod + .GetMethodMembersWithName("NonVirtualMethod()") + .First(); + MethodReturningString = ClassWithStringReturnType + .GetMethodMembersWithName("MethodReturningString()") + .First(); + MethodReturningInt = ClassWithIntReturnType + .GetMethodMembersWithName("MethodReturningInt()") + .First(); + ClassWithVirtualMethodConstructor = ClassWithVirtualMethod + .GetMethodMembersWithName(".ctor()") + .First(); + ClassWithNonVirtualMethodConstructor = ClassWithNonVirtualMethod + .GetMethodMembersWithName(".ctor()") + .First(); + MethodReturningRegularClass = ClassWithRegularClassReturnType + .GetMethodMembersWithName("MethodReturningRegularClass()") + .First(); + MethodReturningOtherRegularClass = ClassWithOtherRegularClassReturnType + .GetMethodMembersWithName("MethodReturningOtherRegularClass()") + .First(); } } diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs index ba31a1b45..05372ba90 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs @@ -1,472 +1,606 @@ -using System.Collections.Generic; -using System.Linq; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; using ArchUnitNET.Domain; -using ArchUnitNET.Domain.Extensions; -using ArchUnitNETTests.Domain; +using ArchUnitNETTests.AssemblyTestHelper; using Xunit; using static ArchUnitNET.Fluent.ArchRuleDefinition; namespace ArchUnitNETTests.Fluent.Syntax.Elements { + // csharpier-ignore public class MethodMemberSyntaxElementsTests { - private static readonly Architecture Architecture = - StaticTestArchitectures.ArchUnitNETTestArchitecture; - private readonly IEnumerable _methodMembers; - private readonly IEnumerable _types; - - public MethodMemberSyntaxElementsTests() + [Fact] + public async Task BeConstructorTest() { - _methodMembers = Architecture.MethodMembers; - _types = Architecture.Types; + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.ClassWithVirtualMethodConstructor).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeConstructor().AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreConstructors()).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.VirtualMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeConstructor().AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreConstructors()).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.ClassWithVirtualMethodConstructor, helper.ClassWithNonVirtualMethodConstructor).Should().BeConstructor().AssertNoViolations(helper); + MethodMembers().That().Are(helper.ClassWithVirtualMethodConstructor, helper.VirtualMethod).Should().BeConstructor().AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void AreConstructorsTest() + public async Task BeNoConstructorTest() { - foreach (var methodMember in _methodMembers) - { - var methodMemberIsConstructor = MethodMembers() - .That() - .Are(methodMember) - .Should() - .BeConstructor(); - var methodMemberIsNoConstructor = MethodMembers() - .That() - .Are(methodMember) - .Should() - .BeNoConstructor(); - var constructorMethodMembersDoNotIncludeMember = MethodMembers() - .That() - .AreConstructors() - .Should() - .NotBe(methodMember) - .OrShould() - .NotExist(); - var noConstructorMethodMembersDoNotIncludeMember = MethodMembers() - .That() - .AreNoConstructors() - .Should() - .NotBe(methodMember) - .AndShould() - .Exist(); - - Assert.Equal( - methodMember.IsConstructor(), - methodMemberIsConstructor.HasNoViolations(Architecture) - ); - Assert.Equal( - !methodMember.IsConstructor(), - methodMemberIsNoConstructor.HasNoViolations(Architecture) - ); - Assert.Equal( - !methodMember.IsConstructor(), - constructorMethodMembersDoNotIncludeMember.HasNoViolations(Architecture) - ); - Assert.Equal( - methodMember.IsConstructor(), - noConstructorMethodMembersDoNotIncludeMember.HasNoViolations(Architecture) - ); - } - - var constructorMethodMembersShouldBeConstructor = MethodMembers() - .That() - .AreConstructors() - .Should() - .BeConstructor(); - var constructorMethodMembersAreNoConstructors = MethodMembers() - .That() - .AreConstructors() - .Should() - .BeNoConstructor() - .AndShould() - .Exist(); - var noConstructorMethodMembersShouldBeConstructor = MethodMembers() - .That() - .AreNoConstructors() - .Should() - .BeConstructor() - .AndShould() - .Exist(); - var noConstructorMethodMembersAreNoConstructors = MethodMembers() - .That() - .AreNoConstructors() - .Should() - .BeNoConstructor(); - - Assert.True(constructorMethodMembersShouldBeConstructor.HasNoViolations(Architecture)); - Assert.False(constructorMethodMembersAreNoConstructors.HasNoViolations(Architecture)); - Assert.False( - noConstructorMethodMembersShouldBeConstructor.HasNoViolations(Architecture) - ); - Assert.True(noConstructorMethodMembersAreNoConstructors.HasNoViolations(Architecture)); + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.VirtualMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeNoConstructor().AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNoConstructors()).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.ClassWithVirtualMethodConstructor).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeNoConstructor().AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNoConstructors()).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.VirtualMethod, helper.NonVirtualMethod).Should().BeNoConstructor().AssertNoViolations(helper); + MethodMembers().That().Are(helper.VirtualMethod, helper.ClassWithVirtualMethodConstructor).Should().BeNoConstructor().AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void AreVirtualTest() + public async Task BeVirtualTest() { - foreach (var methodMember in _methodMembers) - { - var methodMemberIsVirtual = MethodMembers() - .That() - .Are(methodMember) - .Should() - .BeVirtual(); - var methodMemberIsNotVirtual = MethodMembers() - .That() - .Are(methodMember) - .Should() - .NotBeVirtual(); - var virtualMethodMembersDoNotIncludeMember = MethodMembers() - .That() - .AreVirtual() - .Should() - .NotBe(methodMember) - .OrShould() - .NotExist(); - var notVirtualMethodMembersDoNotIncludeMember = MethodMembers() - .That() - .AreNotVirtual() - .Should() - .NotBe(methodMember) - .AndShould() - .Exist(); - - Assert.Equal( - methodMember.IsVirtual, - methodMemberIsVirtual.HasNoViolations(Architecture) - ); - Assert.Equal( - !methodMember.IsVirtual, - methodMemberIsNotVirtual.HasNoViolations(Architecture) - ); - Assert.Equal( - !methodMember.IsVirtual, - virtualMethodMembersDoNotIncludeMember.HasNoViolations(Architecture) - ); - Assert.Equal( - methodMember.IsVirtual, - notVirtualMethodMembersDoNotIncludeMember.HasNoViolations(Architecture) - ); - } - - var virtualMethodMembersShouldBeVirtual = MethodMembers() - .That() - .AreVirtual() - .Should() - .BeVirtual() - .WithoutRequiringPositiveResults(); - var virtualMethodMembersAreNotVirtual = MethodMembers() - .That() - .AreVirtual() - .Should() - .NotBeVirtual() - .AndShould() - .Exist(); - var notVirtualMethodMembersShouldBeVirtual = MethodMembers() - .That() - .AreNotVirtual() - .Should() - .BeVirtual() - .AndShould() - .Exist(); - var notVirtualMethodMembersAreNotVirtual = MethodMembers() - .That() - .AreNotVirtual() - .Should() - .NotBeVirtual(); - - Assert.True(virtualMethodMembersShouldBeVirtual.HasNoViolations(Architecture)); - Assert.False(virtualMethodMembersAreNotVirtual.HasNoViolations(Architecture)); - Assert.False(notVirtualMethodMembersShouldBeVirtual.HasNoViolations(Architecture)); - Assert.True(notVirtualMethodMembersAreNotVirtual.HasNoViolations(Architecture)); + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.VirtualMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeVirtual().AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreVirtual()).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.NonVirtualMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeVirtual().AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreVirtual()).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.VirtualMethod, helper.OtherVirtualMethod).Should().BeVirtual().AssertNoViolations(helper); + MethodMembers().That().Are(helper.VirtualMethod, helper.NonVirtualMethod).Should().BeVirtual().AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void CalledByTest() + public async Task NotBeVirtualTest() { - foreach (var methodMember in _methodMembers) - { - foreach ( - var callingType in methodMember - .GetMethodCallDependencies(true) - .Select(dependency => dependency.Origin) - ) - { - var methodIsCalledByRightType = MethodMembers() - .That() - .Are(methodMember) - .Should() - .BeCalledBy(callingType); - var methodIsNotCalledByRightType = MethodMembers() - .That() - .Are(methodMember) - .Should() - .NotBeCalledBy(callingType); - - Assert.True(methodIsCalledByRightType.HasNoViolations(Architecture)); - Assert.False(methodIsNotCalledByRightType.HasNoViolations(Architecture)); - } - - var methodIsCalledByFalseType = MethodMembers() - .That() - .Are(methodMember) - .Should() - .BeCalledBy(typeof(PublicTestClass)); - var methodIsNotCalledByFalseType = MethodMembers() - .That() - .Are(methodMember) - .Should() - .NotBeCalledBy(typeof(PublicTestClass)); - - Assert.False(methodIsCalledByFalseType.HasNoViolations(Architecture)); - Assert.True(methodIsNotCalledByFalseType.HasNoViolations(Architecture)); - } - - foreach (var type in _types) - { - var calledMethodsShouldBeCalled = MethodMembers() - .That() - .AreCalledBy(type) - .Should() - .BeCalledBy(type) - .WithoutRequiringPositiveResults(); - var notCalledMethodsShouldNotBeCalled = MethodMembers() - .That() - .AreNotCalledBy(type) - .Should() - .NotBeCalledBy(type); - - Assert.True(calledMethodsShouldBeCalled.HasNoViolations(Architecture)); - Assert.True(notCalledMethodsShouldNotBeCalled.HasNoViolations(Architecture)); - } - - var emptyTypeCallsNoMethods = MethodMembers() - .That() - .AreCalledBy(typeof(PublicTestClass)) - .Should() - .NotExist(); - var methodsNotCalledByEmptyTypeShouldExist = MethodMembers() - .That() - .AreNotCalledBy(typeof(PublicTestClass)) - .Should() - .Exist(); - - Assert.True(emptyTypeCallsNoMethods.HasNoViolations(Architecture)); - Assert.True(methodsNotCalledByEmptyTypeShouldExist.HasNoViolations(Architecture)); + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.NonVirtualMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotBeVirtual().AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotVirtual()).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.VirtualMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotBeVirtual().AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotVirtual()).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.NonVirtualMethod, helper.MethodReturningString).Should().NotBeVirtual().AssertNoViolations(helper); + MethodMembers().That().Are(helper.NonVirtualMethod, helper.VirtualMethod).Should().NotBeVirtual().AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void HaveDependencyInMethodBodyTest() + public async Task BeCalledByTest() { - foreach (var methodMember in _methodMembers) - { - foreach ( - var dependency in methodMember - .GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - ) - { - var hasRightDependency = MethodMembers() - .That() - .Are(methodMember) - .Should() - .HaveDependencyInMethodBodyTo(dependency); - var doesNotHaveRightDependency = MethodMembers() - .That() - .Are(methodMember) - .Should() - .NotHaveDependencyInMethodBodyTo(dependency); - - Assert.True(hasRightDependency.HasNoViolations(Architecture)); - Assert.False(doesNotHaveRightDependency.HasNoViolations(Architecture)); - } - } - - foreach (var type in _types) - { - var dependentMethodsShouldBeDependent = MethodMembers() - .That() - .HaveDependencyInMethodBodyTo(type) - .Should() - .HaveDependencyInMethodBodyTo(type) - .WithoutRequiringPositiveResults(); - var notDependentMethodsShouldNotBeDependent = MethodMembers() - .That() - .DoNotHaveDependencyInMethodBodyTo(type) - .Should() - .NotHaveDependencyInMethodBodyTo(type); - - Assert.True(dependentMethodsShouldBeDependent.HasNoViolations(Architecture)); - Assert.True(notDependentMethodsShouldNotBeDependent.HasNoViolations(Architecture)); - } + var helper = new MethodDependencyAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeCalledBy(helper.MethodDependencyClass).AssertNoViolations(helper); + should.BeCalledBy(helper.MethodDependencyClassSystemType).AssertNoViolations(helper); + should.BeCalledBy(Types().That().Are(helper.MethodDependencyClass)).AssertNoViolations(helper); + should.BeCalledBy(new List { helper.MethodDependencyClass }).AssertNoViolations(helper); + should.BeCalledBy(new List { helper.MethodDependencyClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreCalledBy(helper.MethodDependencyClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(helper.MethodDependencyClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(Types().That().Are(helper.MethodDependencyClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { helper.MethodDependencyClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { helper.MethodDependencyClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.MethodWithoutDependencies).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeCalledBy(helper.MethodDependencyClass).AssertOnlyViolations(helper); + should.BeCalledBy(helper.MethodDependencyClassSystemType).AssertOnlyViolations(helper); + should.BeCalledBy(Types().That().Are(helper.MethodDependencyClass)).AssertOnlyViolations(helper); + should.BeCalledBy(new List { helper.MethodDependencyClass }).AssertOnlyViolations(helper); + should.BeCalledBy(new List { helper.MethodDependencyClassSystemType }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreCalledBy(helper.MethodDependencyClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(helper.MethodDependencyClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(Types().That().Are(helper.MethodDependencyClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { helper.MethodDependencyClass })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { helper.MethodDependencyClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple arguments"); + should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeCalledBy(helper.MethodDependencyClass, helper.OtherCallingClass).AssertNoViolations(helper); + should.BeCalledBy(new List { helper.MethodDependencyClass, helper.OtherCallingClass }).AssertNoViolations(helper); + should.BeCalledBy(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType).AssertNoViolations(helper); + should.BeCalledBy(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreCalledBy(helper.MethodDependencyClass, helper.OtherCallingClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { helper.MethodDependencyClass, helper.OtherCallingClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Empty arguments"); + should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + // TODO: Empty IEnumerable/ crashes with InvalidOperationException + // (.First() on empty list) — uncomment when AssertException supports lazy evaluation + // should.BeCalledBy(new List()).AssertException(helper); + // should.BeCalledBy(new List()).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreCalledBy(new List())).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List())).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Type not in architecture"); + should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.CalledMethod, helper.CalledMethod1).Should().BeCalledBy(helper.MethodDependencyClass).AssertNoViolations(helper); + MethodMembers().That().Are(helper.CalledMethod, helper.MethodWithoutDependencies).Should().BeCalledBy(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void HaveReturnTypeConditionTest() + public async Task NotBeCalledByTest() { - var retTypeWithType = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .Should() - .HaveReturnType(typeof(ReturnTypeClass), typeof(void), typeof(string)); - var retTypeWithTypeFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .Should() - .HaveReturnType(typeof(bool)); - - Assert.True(retTypeWithType.HasNoViolations(Architecture)); - Assert.False(retTypeWithTypeFail.HasNoViolations(Architecture)); - - var objectProviderClass = Classes().That().HaveFullNameContaining("ReturnTypeClass"); - var retTypeWithObjectProvider = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodClass") - .Should() - .HaveReturnType(objectProviderClass); - var retTypeWithObjectProviderFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodVoid") - .Should() - .HaveReturnType(objectProviderClass); - - Assert.True(retTypeWithObjectProvider.HasNoViolations(Architecture)); - Assert.False(retTypeWithObjectProviderFail.HasNoViolations(Architecture)); - - var retTypeWithIType = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodClass") - .Should() - .HaveReturnType(objectProviderClass.GetObjects(Architecture).ToList().First()); - var retTypeWithITypeFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodString") - .Should() - .HaveReturnType(objectProviderClass.GetObjects(Architecture).ToList().First()); - - Assert.True(retTypeWithIType.HasNoViolations(Architecture)); - Assert.False(retTypeWithITypeFail.HasNoViolations(Architecture)); + var helper = new MethodDependencyAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.MethodWithoutDependencies).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotBeCalledBy(helper.MethodDependencyClass).AssertNoViolations(helper); + should.NotBeCalledBy(helper.MethodDependencyClassSystemType).AssertNoViolations(helper); + should.NotBeCalledBy(Types().That().Are(helper.MethodDependencyClass)).AssertNoViolations(helper); + should.NotBeCalledBy(new List { helper.MethodDependencyClass }).AssertNoViolations(helper); + should.NotBeCalledBy(new List { helper.MethodDependencyClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotCalledBy(helper.MethodDependencyClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(helper.MethodDependencyClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(Types().That().Are(helper.MethodDependencyClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { helper.MethodDependencyClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { helper.MethodDependencyClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotBeCalledBy(helper.MethodDependencyClass).AssertOnlyViolations(helper); + should.NotBeCalledBy(helper.MethodDependencyClassSystemType).AssertOnlyViolations(helper); + should.NotBeCalledBy(Types().That().Are(helper.MethodDependencyClass)).AssertOnlyViolations(helper); + should.NotBeCalledBy(new List { helper.MethodDependencyClass }).AssertOnlyViolations(helper); + should.NotBeCalledBy(new List { helper.MethodDependencyClassSystemType }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotCalledBy(helper.MethodDependencyClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(helper.MethodDependencyClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(Types().That().Are(helper.MethodDependencyClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { helper.MethodDependencyClass })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { helper.MethodDependencyClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple arguments"); + should = MethodMembers().That().Are(helper.MethodWithoutDependencies).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotBeCalledBy(helper.MethodDependencyClass, helper.OtherCallingClass).AssertNoViolations(helper); + should.NotBeCalledBy(new List { helper.MethodDependencyClass, helper.OtherCallingClass }).AssertNoViolations(helper); + should.NotBeCalledBy(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType).AssertNoViolations(helper); + should.NotBeCalledBy(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotCalledBy(helper.MethodDependencyClass, helper.OtherCallingClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { helper.MethodDependencyClass, helper.OtherCallingClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Empty arguments"); + should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + // TODO: Empty IEnumerable/ crashes with InvalidOperationException + // (.First() on empty list) — uncomment when AssertException supports lazy evaluation + // should.NotBeCalledBy(new List()).AssertException(helper); + // should.NotBeCalledBy(new List()).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotCalledBy(new List())).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List())).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Type not in architecture"); + should = MethodMembers().That().Are(helper.CalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotBeCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreNotCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.MethodWithoutDependencies, helper.MethodCallingCalledMethod).Should().NotBeCalledBy(helper.MethodDependencyClass).AssertNoViolations(helper); + MethodMembers().That().Are(helper.CalledMethod, helper.MethodWithoutDependencies).Should().NotBeCalledBy(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void NotHaveReturnTypeConditionTest() + public async Task HaveDependencyInMethodBodyToTest() { - var retTypeWithType = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .Should() - .NotHaveReturnType(typeof(bool)); - var retTypeWithTypeFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .Should() - .NotHaveReturnType(typeof(ReturnTypeClass), typeof(void), typeof(string)); - - Assert.True(retTypeWithType.HasNoViolations(Architecture)); - Assert.False(retTypeWithTypeFail.HasNoViolations(Architecture)); - - var objectProviderClass = Classes().That().HaveFullNameContaining("ReturnTypeClass"); - var retTypeWithObjectProvider = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodVoid") - .Should() - .NotHaveReturnType(objectProviderClass); - var retTypeWithObjectProviderFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodClass") - .Should() - .NotHaveReturnType(objectProviderClass); - - Assert.True(retTypeWithObjectProvider.HasNoViolations(Architecture)); - Assert.False(retTypeWithObjectProviderFail.HasNoViolations(Architecture)); - - var retTypeWithIType = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodString") - .Should() - .NotHaveReturnType(objectProviderClass.GetObjects(Architecture).ToList().First()); - var retTypeWithITypeFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethodClass") - .Should() - .NotHaveReturnType(objectProviderClass.GetObjects(Architecture).ToList().First()); - - Assert.True(retTypeWithIType.HasNoViolations(Architecture)); - Assert.False(retTypeWithITypeFail.HasNoViolations(Architecture)); + var helper = new MethodDependencyAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(Types().That().Are(helper.MethodDependencyClass)).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass }).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(helper.MethodDependencyClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(Types().That().Are(helper.MethodDependencyClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.MethodWithoutDependencies).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveDependencyInMethodBodyTo(helper.OtherCallingClass).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(helper.OtherCallingClassSystemType).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(Types().That().Are(helper.OtherCallingClass)).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { helper.OtherCallingClass }).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { helper.OtherCallingClassSystemType }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(helper.OtherCallingClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(helper.OtherCallingClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(Types().That().Are(helper.OtherCallingClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { helper.OtherCallingClass })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { helper.OtherCallingClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple arguments"); + should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveDependencyInMethodBodyTo(helper.MethodDependencyClass, helper.OtherCallingClass).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass, helper.OtherCallingClass }).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType).AssertNoViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(helper.MethodDependencyClass, helper.OtherCallingClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass, helper.OtherCallingClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Empty arguments"); + should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + // TODO: Empty IEnumerable/ crashes with InvalidOperationException + // (.First() on empty list) — uncomment when AssertException supports lazy evaluation + // should.HaveDependencyInMethodBodyTo(new List()).AssertException(helper); + // should.HaveDependencyInMethodBodyTo(new List()).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List())).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List())).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Type not in architecture"); + should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.MethodCallingCalledMethod, helper.AnotherMethodCallingCalledMethod).Should().HaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertNoViolations(helper); + MethodMembers().That().Are(helper.MethodCallingCalledMethod, helper.MethodWithoutDependencies).Should().HaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void HaveReturnTypePredicateTest() + public async Task NotHaveDependencyInMethodBodyToTest() { - var retTypeWithType = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .And() - .HaveReturnType(typeof(ReturnTypeClass)) - .Should() - .HaveFullNameContaining("Class"); - var retTypeWithTypeFail = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .And() - .DoNotHaveReturnType(typeof(ReturnTypeClass)) - .Should() - .HaveNameContaining("Class"); - - Assert.True(retTypeWithType.HasNoViolations(Architecture)); - Assert.False(retTypeWithTypeFail.HasNoViolations(Architecture)); - - var objectProviderClass = Classes().That().HaveFullNameContaining("ReturnTypeClass"); - var retTypeWithObjectProvider = MethodMembers() - .That() - .HaveReturnType(objectProviderClass) - .Should() - .HaveFullNameContaining("ReturnTypeMethodClass"); - var retTypeWithObjectProviderFail = MethodMembers() - .That() - .DoNotHaveReturnType(objectProviderClass) - .And() - .HaveFullNameContaining("ReturnTypeMethod") - .Should() - .HaveFullNameContaining("ReturnTypeMethodClass"); - - Assert.True(retTypeWithObjectProvider.HasNoViolations(Architecture)); - Assert.False(retTypeWithObjectProviderFail.HasNoViolations(Architecture)); - - var retTypeWithITypeFail = MethodMembers() - .That() - .HaveReturnType(objectProviderClass.GetObjects(Architecture).ToList().First()) - .Should() - .HaveFullNameContaining("ReturnTypeMethodVoid"); - - var retTypeWithITypeNegate = MethodMembers() - .That() - .HaveFullNameContaining("ReturnTypeMethod") - .And() - .DoNotHaveReturnType(objectProviderClass.GetObjects(Architecture).ToList().First()) - .Should() - .HaveFullNameContaining("String") - .OrShould() - .HaveFullNameContaining("Void"); - - Assert.False(retTypeWithITypeFail.HasNoViolations(Architecture)); - Assert.True(retTypeWithITypeNegate.HasNoViolations(Architecture)); + var helper = new MethodDependencyAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.MethodWithoutDependencies).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveDependencyInMethodBodyTo(helper.OtherCallingClass).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(helper.OtherCallingClassSystemType).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(Types().That().Are(helper.OtherCallingClass)).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { helper.OtherCallingClass }).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { helper.OtherCallingClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(helper.OtherCallingClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(helper.OtherCallingClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(Types().That().Are(helper.OtherCallingClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { helper.OtherCallingClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { helper.OtherCallingClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertOnlyViolations(helper); + should.NotHaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType).AssertOnlyViolations(helper); + should.NotHaveDependencyInMethodBodyTo(Types().That().Are(helper.MethodDependencyClass)).AssertOnlyViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass }).AssertOnlyViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(helper.MethodDependencyClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(Types().That().Are(helper.MethodDependencyClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple arguments"); + should = MethodMembers().That().Are(helper.MethodWithoutDependencies).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveDependencyInMethodBodyTo(helper.MethodDependencyClass, helper.OtherCallingClass).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass, helper.OtherCallingClass }).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(helper.MethodDependencyClass, helper.OtherCallingClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClass, helper.OtherCallingClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { helper.MethodDependencyClassSystemType, helper.OtherCallingClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Empty arguments"); + should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + // TODO: Empty IEnumerable/ crashes with InvalidOperationException + // (.First() on empty list) — uncomment when AssertException supports lazy evaluation + // should.NotHaveDependencyInMethodBodyTo(new List()).AssertException(helper); + // should.NotHaveDependencyInMethodBodyTo(new List()).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List())).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List())).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Type not in architecture"); + should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.MethodWithoutDependencies, helper.CalledMethod).Should().NotHaveDependencyInMethodBodyTo(helper.OtherCallingClass).AssertNoViolations(helper); + MethodMembers().That().Are(helper.MethodCallingCalledMethod, helper.MethodWithoutDependencies).Should().NotHaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } - } - internal class ReturnTypeClass - { - public void ReturnTypeMethodVoid() { } + [Fact] + public async Task HaveReturnTypeTest() + { + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.MethodReturningRegularClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(helper.RegularClass).AssertNoViolations(helper); + should.HaveReturnType(helper.RegularClassSystemType).AssertNoViolations(helper); + should.HaveReturnType(Types().That().Are(helper.RegularClass)).AssertNoViolations(helper); + should.HaveReturnType(new List { helper.RegularClass }).AssertNoViolations(helper); + should.HaveReturnType(new List { helper.RegularClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(helper.RegularClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(helper.RegularClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(Types().That().Are(helper.RegularClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { helper.RegularClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { helper.RegularClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.MethodReturningRegularClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(helper.OtherRegularClass).AssertOnlyViolations(helper); + should.HaveReturnType(helper.OtherRegularClassSystemType).AssertOnlyViolations(helper); + should.HaveReturnType(Types().That().Are(helper.OtherRegularClass)).AssertOnlyViolations(helper); + should.HaveReturnType(new List { helper.OtherRegularClass }).AssertOnlyViolations(helper); + should.HaveReturnType(new List { helper.OtherRegularClassSystemType }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(helper.OtherRegularClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(helper.OtherRegularClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(Types().That().Are(helper.OtherRegularClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { helper.OtherRegularClass })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { helper.OtherRegularClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple arguments"); + should = MethodMembers().That().Are(helper.MethodReturningRegularClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(helper.RegularClass, helper.OtherRegularClass).AssertNoViolations(helper); + should.HaveReturnType(new List { helper.RegularClass, helper.OtherRegularClass }).AssertNoViolations(helper); + should.HaveReturnType(helper.RegularClassSystemType, helper.OtherRegularClassSystemType).AssertNoViolations(helper); + should.HaveReturnType(new List { helper.RegularClassSystemType, helper.OtherRegularClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(helper.RegularClass, helper.OtherRegularClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { helper.RegularClass, helper.OtherRegularClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(helper.RegularClassSystemType, helper.OtherRegularClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { helper.RegularClassSystemType, helper.OtherRegularClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.MethodReturningRegularClass, helper.MethodReturningOtherRegularClass).Should().HaveReturnType(helper.RegularClass).AssertAnyViolations(helper); + MethodMembers().That().Are(helper.MethodReturningRegularClass, helper.MethodReturningOtherRegularClass).Should().HaveReturnType(helper.RegularClass, helper.OtherRegularClass).AssertNoViolations(helper); + + await helper.AssertSnapshotMatches(); + } - public string ReturnTypeMethodString() + [Fact] + public async Task DoNotHaveReturnTypeTest() { - return ""; + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + var should = MethodMembers().That().Are(helper.MethodReturningRegularClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveReturnType(helper.OtherRegularClass).AssertNoViolations(helper); + should.NotHaveReturnType(helper.OtherRegularClassSystemType).AssertNoViolations(helper); + should.NotHaveReturnType(Types().That().Are(helper.OtherRegularClass)).AssertNoViolations(helper); + should.NotHaveReturnType(new List { helper.OtherRegularClass }).AssertNoViolations(helper); + should.NotHaveReturnType(new List { helper.OtherRegularClassSystemType }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClassSystemType)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(Types().That().Are(helper.OtherRegularClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClassSystemType })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + should = MethodMembers().That().Are(helper.MethodReturningRegularClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveReturnType(helper.RegularClass).AssertOnlyViolations(helper); + should.NotHaveReturnType(helper.RegularClassSystemType).AssertOnlyViolations(helper); + should.NotHaveReturnType(Types().That().Are(helper.RegularClass)).AssertOnlyViolations(helper); + should.NotHaveReturnType(new List { helper.RegularClass }).AssertOnlyViolations(helper); + should.NotHaveReturnType(new List { helper.RegularClassSystemType }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.RegularClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.RegularClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(Types().That().Are(helper.RegularClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.RegularClass })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.RegularClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple arguments"); + should = MethodMembers().That().Are(helper.MethodReturningRegularClass).Should(); + + // NotHaveReturnType(IEnumerable) condition uses .All(type => !match) — fails if ANY type matches + // With {OtherRegularClass, RegularClass}: OtherRegularClass doesn't match (true) AND RegularClass matches (false) => All = false => violation + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveReturnType(helper.OtherRegularClass, helper.RegularClass).AssertOnlyViolations(helper); + should.NotHaveReturnType(new List { helper.OtherRegularClass, helper.RegularClass }).AssertOnlyViolations(helper); + should.NotHaveReturnType(helper.OtherRegularClassSystemType, helper.RegularClassSystemType).AssertOnlyViolations(helper); + should.NotHaveReturnType(new List { helper.OtherRegularClassSystemType, helper.RegularClassSystemType }).AssertOnlyViolations(helper); + + // DoNotHaveReturnType predicate uses .Any(type => !match) for IEnumerable — passes if ANY type doesn't match + // With {OtherRegularClass, RegularClass}: OtherRegularClass doesn't match (true) => Any = true => passes + // BUT: IEnumerable and IObjectProvider overloads use .All(type => !match) — fails if ANY type matches + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClass, helper.RegularClass)).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClass, helper.RegularClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClassSystemType, helper.RegularClassSystemType)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClassSystemType, helper.RegularClassSystemType })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.MethodReturningRegularClass, helper.MethodReturningOtherRegularClass).Should().NotHaveReturnType(helper.RegularClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } - public ReturnTypeClass ReturnTypeMethodClass() + [Fact] + public async Task BeMethodMembersThatTest() { - return new ReturnTypeClass(); + var helper = new TypeAssemblyTestHelper(); + + helper.AddSnapshotHeader("No Violations"); + MethodMembers().That().Are(helper.ClassWithVirtualMethodConstructor).Should().BeMethodMembersThat().AreConstructors().AssertNoViolations(helper); + + helper.AddSnapshotHeader("Violations"); + MethodMembers().That().Are(helper.VirtualMethod).Should().BeMethodMembersThat().AreConstructors().AssertOnlyViolations(helper); + + await helper.AssertSnapshotMatches(); } } } diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt new file mode 100644 index 000000000..1f4f27eb7 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt @@ -0,0 +1,285 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false) +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false)" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false) +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false)" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) + + + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "AttributeNamespace.ClassWithoutAttributes" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by "AttributeNamespace.ClassWithoutAttributes" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "AttributeNamespace.ClassWithoutAttributes"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by "AttributeNamespace.ClassWithoutAttributes" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "AttributeNamespace.ClassWithoutAttributes" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by "AttributeNamespace.ClassWithoutAttributes" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "AttributeNamespace.ClassWithoutAttributes"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by "AttributeNamespace.ClassWithoutAttributes" + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependencyClass::... should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod1() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependencyClass::... should be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependencyClass::... should be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodDependencyNamespace.MethodDependencyClass" + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeConstructorTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeConstructorTest.verified.txt new file mode 100644 index 000000000..313caba6f --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeConstructorTest.verified.txt @@ -0,0 +1,63 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be a constructor +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be Method members that are constructors +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor + + + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are constructors +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are constructors +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are constructors" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are constructors + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" should be a constructor +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() passed +Result: True +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt new file mode 100644 index 000000000..976c4d30d --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt @@ -0,0 +1,19 @@ +===== No Violations ===== + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be method members that are constructors +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +===== Violations ===== + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be method members that are constructors +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void TypeNamespace.RegularClass::.ctor()" or "System.Void TypeNamespace.OtherRegularClass::.ctor()" or "System.Void TypeNamespace.ClassWithProperty::.ctor()" or "System.Void TypeNamespace.ClassWithField::.ctor()" or "System.Void TypeNamespace.ClassWithMethod::.ctor()" or "System.Void TypeNamespace.ClassWithAllMembers::.ctor()" or "System.Void TypeNamespace.ClassWithoutMembers::.ctor()" or "System.Void TypeNamespace.OuterClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB::.ctor()" or "System.Void TypeNamespace.NonNestedClass::.ctor()" or "System.Void TypeNamespace.ClassImplementingInterface::.ctor()" or "System.Void TypeNamespace.ClassNotImplementingInterface::.ctor()" or "System.Void TypeNamespace.BaseClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherBaseClassForAssign::.ctor()" or "System.Void TypeNamespace.DerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherDerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.UnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherUnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.ClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithNonStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithReadOnlyField::.ctor()" or "System.Void TypeNamespace.ClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.ClassWithInitOnlyProperty::.ctor()" or "System.Void TypeNamespace.ClassWithGetOnlyProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.cctor()" or "System.Void TypeNamespace.ClassWithStaticMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithStringReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithIntReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.OuterClassA/InnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassA/OtherInnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB/InnerClassB::.ctor()" +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be method members that are constructors" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void TypeNamespace.RegularClass::.ctor()" or "System.Void TypeNamespace.OtherRegularClass::.ctor()" or "System.Void TypeNamespace.ClassWithProperty::.ctor()" or "System.Void TypeNamespace.ClassWithField::.ctor()" or "System.Void TypeNamespace.ClassWithMethod::.ctor()" or "System.Void TypeNamespace.ClassWithAllMembers::.ctor()" or "System.Void TypeNamespace.ClassWithoutMembers::.ctor()" or "System.Void TypeNamespace.OuterClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB::.ctor()" or "System.Void TypeNamespace.NonNestedClass::.ctor()" or "System.Void TypeNamespace.ClassImplementingInterface::.ctor()" or "System.Void TypeNamespace.ClassNotImplementingInterface::.ctor()" or "System.Void TypeNamespace.BaseClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherBaseClassForAssign::.ctor()" or "System.Void TypeNamespace.DerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherDerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.UnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherUnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.ClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithNonStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithReadOnlyField::.ctor()" or "System.Void TypeNamespace.ClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.ClassWithInitOnlyProperty::.ctor()" or "System.Void TypeNamespace.ClassWithGetOnlyProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.cctor()" or "System.Void TypeNamespace.ClassWithStaticMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithStringReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithIntReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.OuterClassA/InnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassA/OtherInnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB/InnerClassB::.ctor()" + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeNoConstructorTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeNoConstructorTest.verified.txt new file mode 100644 index 000000000..dc0d56fd0 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeNoConstructorTest.verified.txt @@ -0,0 +1,63 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be no constructor +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are no constructors +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() is a constructor +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() is a constructor + + + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be Method members that are no constructors +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() is not Method members that are no constructors +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be Method members that are no constructors" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() is not Method members that are no constructors + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be no constructor +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: True +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() is a constructor +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::.ctor() is a constructor + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeVirtualTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeVirtualTest.verified.txt new file mode 100644 index 000000000..479afa235 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeVirtualTest.verified.txt @@ -0,0 +1,63 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be virtual +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are virtual +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be virtual +Result: False +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual +Message: +"Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be virtual" failed: + System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual + + + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be Method members that are virtual +Result: False +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not Method members that are virtual +Message: +"Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be Method members that are virtual" failed: + System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not Method members that are virtual + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::OtherVirtualMeth... should be virtual +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: True +Description: System.Void TypeNamespace.OtherClassWithVirtualMethod::OtherVirtualMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be virtual +Result: True +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: False +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be virtual" failed: + System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt new file mode 100644 index 000000000..016269181 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt @@ -0,0 +1,247 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type Types that are "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type Types that are "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type Types that are "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type Types that are "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type Types that are "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type Types that are "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type Types that are "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type Types that are "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.RegularClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" + + + +===== Multiple inputs ===== + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "TypeNamespace.OtherRegularClass T... should not have return type "TypeNamespace.RegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.OtherRegularClass TypeNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() passed +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "TypeNamespace.OtherRegularClass T... should not have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt new file mode 100644 index 000000000..1c255b1fd --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt @@ -0,0 +1,285 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false) +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false)" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false) +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false)" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) + + + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodDependencyNamespace.OtherCallingCl... should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::AnotherMethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependen... should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependen... should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt new file mode 100644 index 000000000..3f12ef4d5 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt @@ -0,0 +1,237 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type Types that are "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type Types that are "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type Types that are "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type Types that are "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "TypeNamespace.RegularClass" + + + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type Types that are "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type Types that are "TypeNamespace.OtherRegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type Types that are "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type Types that are "TypeNamespace.OtherRegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass" +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.OtherRegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "TypeNamespace.OtherRegularClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +===== Multiple inputs ===== + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "TypeNamespace.OtherRegularClass T... should have return type "TypeNamespace.RegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Result: False +Description: TypeNamespace.OtherRegularClass TypeNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() has return type "TypeNamespace.OtherRegularClass" +Message: +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "TypeNamespace.OtherRegularClass T... should have return type "TypeNamespace.RegularClass"" failed: + TypeNamespace.OtherRegularClass TypeNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() has return type "TypeNamespace.OtherRegularClass" + + + +Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "TypeNamespace.OtherRegularClass T... should have return type "TypeNamespace.RegularClass" or "TypeNamespace.OtherRegularClass" +Result: True +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Result: True +Description: TypeNamespace.OtherRegularClass TypeNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() passed +Message: +All Evaluations passed + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt new file mode 100644 index 000000000..e53178654 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt @@ -0,0 +1,273 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by Types that are "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always false) +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "AttributeNamespace.ClassWithoutAttributes" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "AttributeNamespace.ClassWithoutAttributes" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" or "System.Void MethodDependencyNamespace.OtherCalli... should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependencyClass::... should not be called by "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependencyClass::... should not be called by "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by "MethodDependencyNamespace.MethodDependencyClass" + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeVirtualTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeVirtualTest.verified.txt new file mode 100644 index 000000000..dfb2195a4 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeVirtualTest.verified.txt @@ -0,0 +1,63 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should not be virtual +Result: True +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be Method members that are not virtual +Result: True +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should not be virtual +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should not be virtual" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual + + + +----- Predicates ----- + +Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are not virtual +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are not virtual +Message: +"Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are not virtual" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are not virtual + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" or "System.String TypeNamespace.ClassWithStringReturnType::MethodRetu... should not be virtual +Result: True +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Result: True +Description: System.String TypeNamespace.ClassWithStringReturnType::MethodReturningString() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" or "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should not be virtual +Result: False +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual +Result: True +Description: System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +"Method members that are "System.Void TypeNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" or "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should not be virtual" failed: + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt new file mode 100644 index 000000000..4662d45ec --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt @@ -0,0 +1,273 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" or "System.Void MethodDependencyNamespace.MethodDepe... should not have dependencies in method body to "MethodDependencyNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependen... should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodDependencyNamespace.MethodDependen... should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" + + + diff --git a/TestAssemblies/MethodDependencyAssembly/MethodDependency.cs b/TestAssemblies/MethodDependencyAssembly/MethodDependency.cs index b57bea6e2..352b24231 100644 --- a/TestAssemblies/MethodDependencyAssembly/MethodDependency.cs +++ b/TestAssemblies/MethodDependencyAssembly/MethodDependency.cs @@ -24,3 +24,18 @@ public void CalledMethod3() { } public void MethodWithoutDependencies() { } } + +public class OtherCallingClass +{ + public void MethodCallingCalledMethod() + { + var dep = new MethodDependencyClass(); + dep.CalledMethod(); + } + + public void AnotherMethodCallingCalledMethod() + { + var dep = new MethodDependencyClass(); + dep.CalledMethod1(); + } +} diff --git a/TestAssemblies/TypeAssembly/Type.cs b/TestAssemblies/TypeAssembly/Type.cs index 3a6d36f96..6a0955d07 100644 --- a/TestAssemblies/TypeAssembly/Type.cs +++ b/TestAssemblies/TypeAssembly/Type.cs @@ -152,3 +152,51 @@ public class ClassWithStaticMethod { public static void StaticMethod() { } } + +// Method member test classes +public class ClassWithVirtualMethod +{ + public virtual void VirtualMethod() { } +} + +public class OtherClassWithVirtualMethod +{ + public virtual void OtherVirtualMethod() { } +} + +public class ClassWithNonVirtualMethod +{ + public void NonVirtualMethod() { } +} + +public class ClassWithStringReturnType +{ + public string MethodReturningString() + { + return ""; + } +} + +public class ClassWithIntReturnType +{ + public int MethodReturningInt() + { + return 0; + } +} + +public class ClassWithRegularClassReturnType +{ + public RegularClass MethodReturningRegularClass() + { + return new RegularClass(); + } +} + +public class ClassWithOtherRegularClassReturnType +{ + public OtherRegularClass MethodReturningOtherRegularClass() + { + return new OtherRegularClass(); + } +} From 972b456c11ea189d4dca6cdf24658f499de1c1bc Mon Sep 17 00:00:00 2001 From: Alexander Linne Date: Fri, 12 Jun 2026 14:48:19 +0200 Subject: [PATCH 2/2] refactor: deduplicate implementation of method member syntax elements Signed-off-by: Alexander Linne --- .../MethodMembers/AddMethodMemberCondition.cs | 51 +- .../MethodMembers/AddMethodMemberPredicate.cs | 51 +- .../IAddMethodMemberCondition.cs | 36 +- .../IAddMethodMemberPredicate.cs | 36 +- .../MethodMemberConditionsDefinition.cs | 1039 +++-------------- .../MethodMemberPredicatesDefinition.cs | 618 ++-------- .../TypeAssemblyTestHelper.cs | 29 + .../Elements/MatchGenericReturnTypesTests.cs | 218 ---- .../MethodMemberSyntaxElementsTests.cs | 126 +- ...xElementsTests.BeCalledByTest.verified.txt | 82 +- ...Tests.BeMethodMembersThatTest.verified.txt | 4 +- ...Tests.DoNotHaveReturnTypeTest.verified.txt | 132 ++- ...eDependencyInMethodBodyToTest.verified.txt | 82 +- ...mentsTests.HaveReturnTypeTest.verified.txt | 120 ++ ...ementsTests.NotBeCalledByTest.verified.txt | 56 +- ...eDependencyInMethodBodyToTest.verified.txt | 54 +- TestAssemblies/TypeAssembly/Type.cs | 23 + 17 files changed, 919 insertions(+), 1838 deletions(-) delete mode 100644 ArchUnitNETTests/Fluent/Syntax/Elements/MatchGenericReturnTypesTests.cs diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberCondition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberCondition.cs index c2a001207..ace9401a2 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberCondition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberCondition.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using ArchUnitNET.Domain; +using ArchUnitNET.Domain.Extensions; using ArchUnitNET.Fluent.Conditions; namespace ArchUnitNET.Fluent.Syntax.Elements.Members.MethodMembers @@ -17,22 +18,25 @@ internal AddMethodMemberCondition(IArchRuleCreator ruleCreator) public TNextElement BeVirtual() => CreateNextElement(MethodMemberConditionsDefinition.BeVirtual()); - public TNextElement BeCalledBy(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.BeCalledBy(firstType, moreTypes)); - public TNextElement BeCalledBy(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.BeCalledBy(type, moreTypes)); + public TNextElement BeCalledBy() => BeCalledBy(new ObjectProvider()); + public TNextElement BeCalledBy(params IType[] types) => BeCalledBy(new ObjectProvider(types)); + public TNextElement BeCalledBy(params Type[] types) => BeCalledBy(new SystemTypeObjectProvider(types)); public TNextElement BeCalledBy(IObjectProvider types) => CreateNextElement(MethodMemberConditionsDefinition.BeCalledBy(types)); - public TNextElement BeCalledBy(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.BeCalledBy(types)); - public TNextElement BeCalledBy(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.BeCalledBy(types)); + public TNextElement BeCalledBy(IEnumerable types) => BeCalledBy(new ObjectProvider(types)); + public TNextElement BeCalledBy(IEnumerable types) => BeCalledBy(new SystemTypeObjectProvider(types)); - public TNextElement HaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo(firstType, moreTypes)); - public TNextElement HaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo(type, moreTypes)); + public TNextElement HaveDependencyInMethodBodyTo() => HaveDependencyInMethodBodyTo(new ObjectProvider()); + public TNextElement HaveDependencyInMethodBodyTo(params IType[] types) => HaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement HaveDependencyInMethodBodyTo(params Type[] types) => HaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); public TNextElement HaveDependencyInMethodBodyTo(IObjectProvider types) => CreateNextElement(MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo(types)); - public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo(types)); - public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.HaveDependencyInMethodBodyTo(types)); + public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => HaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => HaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); - public TNextElement HaveReturnType(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(firstType, moreTypes)); - public TNextElement HaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(types)); + public TNextElement HaveReturnType() => HaveReturnType(new ObjectProvider()); + public TNextElement HaveReturnType(params IType[] types) => HaveReturnType(new ObjectProvider(types)); + public TNextElement HaveReturnType(params Type[] types) => HaveReturnType((IEnumerable)types); public TNextElement HaveReturnType(IObjectProvider types) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(types)); - public TNextElement HaveReturnType(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(type, moreTypes)); + public TNextElement HaveReturnType(IEnumerable types) => HaveReturnType(new ObjectProvider(types)); public TNextElement HaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(types)); public ShouldRelateToMethodMembersThat BeMethodMembersThat() => BeginComplexMethodMemberCondition(MethodMemberConditionsDefinition.BeMethodMembersThat()); @@ -43,22 +47,25 @@ internal AddMethodMemberCondition(IArchRuleCreator ruleCreator) public TNextElement NotBeVirtual() => CreateNextElement(MethodMemberConditionsDefinition.NotBeVirtual()); - public TNextElement NotBeCalledBy(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.NotBeCalledBy(firstType, moreTypes)); - public TNextElement NotBeCalledBy(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.NotBeCalledBy(type, moreTypes)); + public TNextElement NotBeCalledBy() => NotBeCalledBy(new ObjectProvider()); + public TNextElement NotBeCalledBy(params IType[] types) => NotBeCalledBy(new ObjectProvider(types)); + public TNextElement NotBeCalledBy(params Type[] types) => NotBeCalledBy(new SystemTypeObjectProvider(types)); public TNextElement NotBeCalledBy(IObjectProvider types) => CreateNextElement(MethodMemberConditionsDefinition.NotBeCalledBy(types)); - public TNextElement NotBeCalledBy(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.NotBeCalledBy(types)); - public TNextElement NotBeCalledBy(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.NotBeCalledBy(types)); + public TNextElement NotBeCalledBy(IEnumerable types) => NotBeCalledBy(new ObjectProvider(types)); + public TNextElement NotBeCalledBy(IEnumerable types) => NotBeCalledBy(new SystemTypeObjectProvider(types)); - public TNextElement NotHaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo(firstType, moreTypes)); - public TNextElement NotHaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo(type, moreTypes)); + public TNextElement NotHaveDependencyInMethodBodyTo() => NotHaveDependencyInMethodBodyTo(new ObjectProvider()); + public TNextElement NotHaveDependencyInMethodBodyTo(params IType[] types) => NotHaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement NotHaveDependencyInMethodBodyTo(params Type[] types) => NotHaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); public TNextElement NotHaveDependencyInMethodBodyTo(IObjectProvider types) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo(types)); - public TNextElement NotHaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo(types)); - public TNextElement NotHaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveDependencyInMethodBodyTo(types)); + public TNextElement NotHaveDependencyInMethodBodyTo(IEnumerable types) => NotHaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement NotHaveDependencyInMethodBodyTo(IEnumerable types) => NotHaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); - public TNextElement NotHaveReturnType(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveReturnType(firstType, moreTypes)); - public TNextElement NotHaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveReturnType(types)); + public TNextElement NotHaveReturnType() => NotHaveReturnType(new ObjectProvider()); + public TNextElement NotHaveReturnType(params IType[] types) => NotHaveReturnType(new ObjectProvider(types)); + public TNextElement NotHaveReturnType(params Type[] types) => NotHaveReturnType((IEnumerable)types); public TNextElement NotHaveReturnType(IObjectProvider types) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveReturnType(types)); - public TNextElement NotHaveReturnType(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveReturnType(type, moreTypes)); + public TNextElement NotHaveReturnType(IEnumerable types) => NotHaveReturnType(new ObjectProvider(types)); public TNextElement NotHaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberConditionsDefinition.NotHaveReturnType(types)); // csharpier-ignore-end } diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberPredicate.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberPredicate.cs index c36993def..33a98d8e3 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberPredicate.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/AddMethodMemberPredicate.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using ArchUnitNET.Domain; +using ArchUnitNET.Domain.Extensions; namespace ArchUnitNET.Fluent.Syntax.Elements.Members.MethodMembers { @@ -17,22 +18,25 @@ internal AddMethodMemberPredicate(IArchRuleCreator ruleCreator) public TNextElement AreVirtual() => CreateNextElement(MethodMemberPredicatesDefinition.AreVirtual()); - public TNextElement AreCalledBy(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.AreCalledBy(firstType, moreTypes)); - public TNextElement AreCalledBy(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.AreCalledBy(type, moreTypes)); + public TNextElement AreCalledBy() => AreCalledBy(new ObjectProvider()); + public TNextElement AreCalledBy(params IType[] types) => AreCalledBy(new ObjectProvider(types)); + public TNextElement AreCalledBy(params Type[] types) => AreCalledBy(new SystemTypeObjectProvider(types)); public TNextElement AreCalledBy(IObjectProvider types) => CreateNextElement(MethodMemberPredicatesDefinition.AreCalledBy(types)); - public TNextElement AreCalledBy(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.AreCalledBy(types)); - public TNextElement AreCalledBy(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.AreCalledBy(types)); + public TNextElement AreCalledBy(IEnumerable types) => AreCalledBy(new ObjectProvider(types)); + public TNextElement AreCalledBy(IEnumerable types) => AreCalledBy(new SystemTypeObjectProvider(types)); - public TNextElement HaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo(firstType, moreTypes)); - public TNextElement HaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo(type, moreTypes)); + public TNextElement HaveDependencyInMethodBodyTo() => HaveDependencyInMethodBodyTo(new ObjectProvider()); + public TNextElement HaveDependencyInMethodBodyTo(params IType[] types) => HaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement HaveDependencyInMethodBodyTo(params Type[] types) => HaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); public TNextElement HaveDependencyInMethodBodyTo(IObjectProvider types) => CreateNextElement(MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo(types)); - public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo(types)); - public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.HaveDependencyInMethodBodyTo(types)); + public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => HaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement HaveDependencyInMethodBodyTo(IEnumerable types) => HaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); - public TNextElement HaveReturnType(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.HaveReturnType(firstType, moreTypes)); - public TNextElement HaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.HaveReturnType(types)); + public TNextElement HaveReturnType() => HaveReturnType(new ObjectProvider()); + public TNextElement HaveReturnType(params IType[] types) => HaveReturnType(new ObjectProvider(types)); + public TNextElement HaveReturnType(params Type[] types) => HaveReturnType((IEnumerable)types); public TNextElement HaveReturnType(IObjectProvider types) => CreateNextElement(MethodMemberPredicatesDefinition.HaveReturnType(types)); - public TNextElement HaveReturnType(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.HaveReturnType(type, moreTypes)); + public TNextElement HaveReturnType(IEnumerable types) => HaveReturnType(new ObjectProvider(types)); public TNextElement HaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.HaveReturnType(types)); //Negations @@ -41,22 +45,25 @@ internal AddMethodMemberPredicate(IArchRuleCreator ruleCreator) public TNextElement AreNotVirtual() => CreateNextElement(MethodMemberPredicatesDefinition.AreNotVirtual()); - public TNextElement AreNotCalledBy(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.AreNotCalledBy(firstType, moreTypes)); - public TNextElement AreNotCalledBy(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.AreNotCalledBy(type, moreTypes)); + public TNextElement AreNotCalledBy() => AreNotCalledBy(new ObjectProvider()); + public TNextElement AreNotCalledBy(params IType[] types) => AreNotCalledBy(new ObjectProvider(types)); + public TNextElement AreNotCalledBy(params Type[] types) => AreNotCalledBy(new SystemTypeObjectProvider(types)); public TNextElement AreNotCalledBy(IObjectProvider types) => CreateNextElement(MethodMemberPredicatesDefinition.AreNotCalledBy(types)); - public TNextElement AreNotCalledBy(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.AreNotCalledBy(types)); - public TNextElement AreNotCalledBy(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.AreNotCalledBy(types)); + public TNextElement AreNotCalledBy(IEnumerable types) => AreNotCalledBy(new ObjectProvider(types)); + public TNextElement AreNotCalledBy(IEnumerable types) => AreNotCalledBy(new SystemTypeObjectProvider(types)); - public TNextElement DoNotHaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo(firstType, moreTypes)); - public TNextElement DoNotHaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo(type, moreTypes)); + public TNextElement DoNotHaveDependencyInMethodBodyTo() => DoNotHaveDependencyInMethodBodyTo(new ObjectProvider()); + public TNextElement DoNotHaveDependencyInMethodBodyTo(params IType[] types) => DoNotHaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement DoNotHaveDependencyInMethodBodyTo(params Type[] types) => DoNotHaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); public TNextElement DoNotHaveDependencyInMethodBodyTo(IObjectProvider types) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo(types)); - public TNextElement DoNotHaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo(types)); - public TNextElement DoNotHaveDependencyInMethodBodyTo(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveDependencyInMethodBodyTo(types)); + public TNextElement DoNotHaveDependencyInMethodBodyTo(IEnumerable types) => DoNotHaveDependencyInMethodBodyTo(new ObjectProvider(types)); + public TNextElement DoNotHaveDependencyInMethodBodyTo(IEnumerable types) => DoNotHaveDependencyInMethodBodyTo(new SystemTypeObjectProvider(types)); - public TNextElement DoNotHaveReturnType(IType firstType, params IType[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveReturnType(firstType, moreTypes)); - public TNextElement DoNotHaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveReturnType(types)); + public TNextElement DoNotHaveReturnType() => DoNotHaveReturnType(new ObjectProvider()); + public TNextElement DoNotHaveReturnType(params IType[] types) => DoNotHaveReturnType(new ObjectProvider(types)); + public TNextElement DoNotHaveReturnType(params Type[] types) => DoNotHaveReturnType((IEnumerable)types); public TNextElement DoNotHaveReturnType(IObjectProvider types) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveReturnType(types)); - public TNextElement DoNotHaveReturnType(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveReturnType(type, moreTypes)); + public TNextElement DoNotHaveReturnType(IEnumerable types) => DoNotHaveReturnType(new ObjectProvider(types)); public TNextElement DoNotHaveReturnType(IEnumerable types) => CreateNextElement(MethodMemberPredicatesDefinition.DoNotHaveReturnType(types)); // csharpier-ignore-end diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberCondition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberCondition.cs index cc559b773..15af4a0a0 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberCondition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberCondition.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using ArchUnitNET.Domain; @@ -11,22 +11,25 @@ public interface IAddMethodMemberCondition TNextElement BeConstructor(); TNextElement BeVirtual(); - TNextElement BeCalledBy(IType firstType, params IType[] moreTypes); - TNextElement BeCalledBy(Type type, params Type[] moreTypes); + TNextElement BeCalledBy(); + TNextElement BeCalledBy(params IType[] types); + TNextElement BeCalledBy(params Type[] types); TNextElement BeCalledBy(IObjectProvider types); TNextElement BeCalledBy(IEnumerable types); TNextElement BeCalledBy(IEnumerable types); - TNextElement HaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes); - TNextElement HaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes); + TNextElement HaveDependencyInMethodBodyTo(); + TNextElement HaveDependencyInMethodBodyTo(params IType[] types); + TNextElement HaveDependencyInMethodBodyTo(params Type[] types); TNextElement HaveDependencyInMethodBodyTo(IObjectProvider types); TNextElement HaveDependencyInMethodBodyTo(IEnumerable types); TNextElement HaveDependencyInMethodBodyTo(IEnumerable types); - TNextElement HaveReturnType(IType firstType, params IType[] moreTypes); - TNextElement HaveReturnType(IEnumerable types); + TNextElement HaveReturnType(); + TNextElement HaveReturnType(params IType[] types); + TNextElement HaveReturnType(params Type[] types); TNextElement HaveReturnType(IObjectProvider types); - TNextElement HaveReturnType(Type type, params Type[] moreTypes); + TNextElement HaveReturnType(IEnumerable types); TNextElement HaveReturnType(IEnumerable types); //Negations @@ -34,22 +37,25 @@ public interface IAddMethodMemberCondition TNextElement BeNoConstructor(); TNextElement NotBeVirtual(); - TNextElement NotBeCalledBy(IType firstType, params IType[] moreTypes); - TNextElement NotBeCalledBy(Type type, params Type[] moreTypes); + TNextElement NotBeCalledBy(); + TNextElement NotBeCalledBy(params IType[] types); + TNextElement NotBeCalledBy(params Type[] types); TNextElement NotBeCalledBy(IObjectProvider types); TNextElement NotBeCalledBy(IEnumerable types); TNextElement NotBeCalledBy(IEnumerable types); - TNextElement NotHaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes); - TNextElement NotHaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes); + TNextElement NotHaveDependencyInMethodBodyTo(); + TNextElement NotHaveDependencyInMethodBodyTo(params IType[] types); + TNextElement NotHaveDependencyInMethodBodyTo(params Type[] types); TNextElement NotHaveDependencyInMethodBodyTo(IObjectProvider types); TNextElement NotHaveDependencyInMethodBodyTo(IEnumerable types); TNextElement NotHaveDependencyInMethodBodyTo(IEnumerable types); - TNextElement NotHaveReturnType(IType firstType, params IType[] moreTypes); - TNextElement NotHaveReturnType(IEnumerable types); + TNextElement NotHaveReturnType(); + TNextElement NotHaveReturnType(params IType[] types); + TNextElement NotHaveReturnType(params Type[] types); TNextElement NotHaveReturnType(IObjectProvider types); - TNextElement NotHaveReturnType(Type type, params Type[] moreTypes); + TNextElement NotHaveReturnType(IEnumerable types); TNextElement NotHaveReturnType(IEnumerable types); } } diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberPredicate.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberPredicate.cs index 4e81ced73..dadd93413 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberPredicate.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/IAddMethodMemberPredicate.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using ArchUnitNET.Domain; @@ -11,22 +11,25 @@ public interface IAddMethodMemberPredicate TNextElement AreConstructors(); TNextElement AreVirtual(); - TNextElement AreCalledBy(IType firstType, params IType[] moreTypes); - TNextElement AreCalledBy(Type type, params Type[] moreTypes); + TNextElement AreCalledBy(); + TNextElement AreCalledBy(params IType[] types); + TNextElement AreCalledBy(params Type[] types); TNextElement AreCalledBy(IObjectProvider types); TNextElement AreCalledBy(IEnumerable types); TNextElement AreCalledBy(IEnumerable types); - TNextElement HaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes); - TNextElement HaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes); + TNextElement HaveDependencyInMethodBodyTo(); + TNextElement HaveDependencyInMethodBodyTo(params IType[] types); + TNextElement HaveDependencyInMethodBodyTo(params Type[] types); TNextElement HaveDependencyInMethodBodyTo(IObjectProvider types); TNextElement HaveDependencyInMethodBodyTo(IEnumerable types); TNextElement HaveDependencyInMethodBodyTo(IEnumerable types); - TNextElement HaveReturnType(IType firstType, params IType[] moreTypes); - TNextElement HaveReturnType(IEnumerable types); + TNextElement HaveReturnType(); + TNextElement HaveReturnType(params IType[] types); + TNextElement HaveReturnType(params Type[] types); TNextElement HaveReturnType(IObjectProvider types); - TNextElement HaveReturnType(Type type, params Type[] moreTypes); + TNextElement HaveReturnType(IEnumerable types); TNextElement HaveReturnType(IEnumerable types); //Negations @@ -34,22 +37,25 @@ public interface IAddMethodMemberPredicate TNextElement AreNoConstructors(); TNextElement AreNotVirtual(); - TNextElement AreNotCalledBy(IType firstType, params IType[] moreTypes); - TNextElement AreNotCalledBy(Type type, params Type[] moreTypes); + TNextElement AreNotCalledBy(); + TNextElement AreNotCalledBy(params IType[] types); + TNextElement AreNotCalledBy(params Type[] types); TNextElement AreNotCalledBy(IObjectProvider types); TNextElement AreNotCalledBy(IEnumerable types); TNextElement AreNotCalledBy(IEnumerable types); - TNextElement DoNotHaveDependencyInMethodBodyTo(IType firstType, params IType[] moreTypes); - TNextElement DoNotHaveDependencyInMethodBodyTo(Type type, params Type[] moreTypes); + TNextElement DoNotHaveDependencyInMethodBodyTo(); + TNextElement DoNotHaveDependencyInMethodBodyTo(params IType[] types); + TNextElement DoNotHaveDependencyInMethodBodyTo(params Type[] types); TNextElement DoNotHaveDependencyInMethodBodyTo(IObjectProvider types); TNextElement DoNotHaveDependencyInMethodBodyTo(IEnumerable types); TNextElement DoNotHaveDependencyInMethodBodyTo(IEnumerable types); - TNextElement DoNotHaveReturnType(IType firstType, params IType[] moreTypes); - TNextElement DoNotHaveReturnType(IEnumerable types); + TNextElement DoNotHaveReturnType(); + TNextElement DoNotHaveReturnType(params IType[] types); + TNextElement DoNotHaveReturnType(params Type[] types); TNextElement DoNotHaveReturnType(IObjectProvider types); - TNextElement DoNotHaveReturnType(Type type, params Type[] moreTypes); + TNextElement DoNotHaveReturnType(IEnumerable types); TNextElement DoNotHaveReturnType(IEnumerable types); } } diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs index b2739b35c..b5205d2a2 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberConditionsDefinition.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using ArchUnitNET.Domain; -using ArchUnitNET.Domain.Exceptions; using ArchUnitNET.Domain.Extensions; using ArchUnitNET.Fluent.Conditions; +using static ArchUnitNET.Domain.Extensions.EnumerableExtensions; namespace ArchUnitNET.Fluent.Syntax.Elements.Members.MethodMembers { @@ -37,26 +37,6 @@ public static IOrderedCondition BeVirtual() ); } - public static IOrderedCondition BeCalledBy( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return BeCalledBy(types); - } - - public static IOrderedCondition BeCalledBy( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return BeCalledBy(types); - } - public static IOrderedCondition BeCalledBy( IObjectProvider objectProvider ) @@ -66,186 +46,32 @@ IEnumerable Condition( Architecture architecture ) { - var typeList = objectProvider.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => methodMember.GetCallingTypes().Intersect(typeList).Any()) - .ToList(); - var failDescription = "is not called by " + objectProvider.Description; - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in passedObjects) - { - yield return new ConditionResult(passedObject, true); - } - } - - var description = "be called by " + objectProvider.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition BeCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - var firstType = typeList.First(); - - IEnumerable Condition(IEnumerable methodMembers) - { - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => methodMember.GetCallingTypes().Intersect(typeList).Any()) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = "is not called by one of no types (always true)"; - } - else - { - failDescription = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "is not called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in passedObjects) - { - yield return new ConditionResult(passedObject, true); - } - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = "be called by one of no types (always false)"; - } - else - { - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "be called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new EnumerableCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition BeCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - var firstType = typeList.First(); - - IEnumerable Condition( - IEnumerable methodMembers, - Architecture architecture - ) - { - var archUnitTypeList = new List(); - foreach (var type in typeList) + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - try + if (methodMember.GetCallingTypes().Any(isRequiredType)) { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); + yield return new ConditionResult(methodMember, true); } - catch (TypeDoesNotExistInArchitecture) + else { - //ignore, can't have a dependency anyways - } - } - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => - methodMember.GetCallingTypes().Intersect(archUnitTypeList).Any() - ) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = "is not called by one of no types (always true)"; - } - else - { - failDescription = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "is not called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" + yield return new ConditionResult( + methodMember, + false, + "is not called by " + objectProvider.Description ); + } } - - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in passedObjects) - { - yield return new ConditionResult(passedObject, true); - } - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = "be called by one of no types (always false)"; - } - else - { - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "be called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); } - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition HaveDependencyInMethodBodyTo( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveDependencyInMethodBodyTo(types); - } - - public static IOrderedCondition HaveDependencyInMethodBodyTo( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveDependencyInMethodBodyTo(types); + var description = objectProvider.FormatDescription( + "be called by one of no types (impossible)", + "be called by", + "be called by any" + ); + return new OrderedArchitectureCondition(Condition, description); } public static IOrderedCondition HaveDependencyInMethodBodyTo( @@ -257,287 +83,111 @@ IEnumerable Condition( Architecture architecture ) { - var typeList = objectProvider.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => - methodMember - .GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(typeList) - .Any() - ) - .ToList(); - var failDescription = - "does not have dependencies in method body to " + objectProvider.Description; - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in passedObjects) + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - yield return new ConditionResult(passedObject, true); - } - } - - var description = "have dependencies in method body to " + objectProvider.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition HaveDependencyInMethodBodyTo( - IEnumerable types - ) - { - var typeList = types.ToList(); - var firstType = typeList.First(); - - IEnumerable Condition(IEnumerable methodMembers) - { - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => + if ( methodMember .GetBodyTypeMemberDependencies() .Select(dependency => dependency.Target) - .Intersect(typeList) - .Any() + .Any(isRequiredType) ) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = - "does not have dependencies in method body to one of no types (always true)"; - } - else - { - failDescription = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "does not have dependencies in method body to \"" - + firstType.FullName - + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" + { + yield return new ConditionResult(methodMember, true); + } + else + { + yield return new ConditionResult( + methodMember, + false, + "does not have dependencies in method body to " + + objectProvider.Description ); + } } - - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in passedObjects) - { - yield return new ConditionResult(passedObject, true); - } - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = "have dependencies in method body to one of no types (always false)"; - } - else - { - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); } - return new EnumerableCondition( - Condition, - description - ).AsOrderedCondition(); + var description = objectProvider.FormatDescription( + "have dependencies in method body to one of no types (impossible)", + "have dependencies in method body to", + "have dependencies in method body to any" + ); + return new OrderedArchitectureCondition(Condition, description); } - public static IOrderedCondition HaveDependencyInMethodBodyTo( - IEnumerable types + public static IOrderedCondition HaveReturnType( + IObjectProvider objectProvider ) { - var typeList = types.ToList(); - var firstType = typeList.First(); - IEnumerable Condition( IEnumerable methodMembers, Architecture architecture ) { - var archUnitTypeList = new List(); - foreach (var type in typeList) + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - try + if (isRequiredType(methodMember.ReturnType)) { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); + yield return new ConditionResult(methodMember, true); } - catch (TypeDoesNotExistInArchitecture) + else { - //ignore, can't have a dependency anyways - } - } - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => - methodMember - .GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(archUnitTypeList) - .Any() - ) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = - "does not have dependencies in method body to one of no types (always true)"; - } - else - { - failDescription = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "does not have dependencies in method body to \"" - + firstType.FullName - + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" + yield return new ConditionResult( + methodMember, + false, + "has return type \"" + methodMember.ReturnType.FullName + "\"" ); - } - - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in passedObjects) - { - yield return new ConditionResult(passedObject, true); + } } } - string description; - if (typeList.IsNullOrEmpty()) - { - description = "have dependencies in method body to one of no types (always false)"; - } - else - { - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition HaveReturnType( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveReturnType(types); + var description = objectProvider.FormatDescription( + "have return type of no types (impossible)", + "have return type", + "have return type" + ); + return new OrderedArchitectureCondition(Condition, description); } - public static IOrderedCondition HaveReturnType(IEnumerable types) + public static IOrderedCondition HaveReturnType(IEnumerable types) { var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.FullName).ToList(); - var description = - "have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - bool Condition(MethodMember member) - { - return typeList.Any(type => member.ReturnType.FullNameEquals(type.FullName)); - } - - return new SimpleCondition( - Condition, - member => "has return type \"" + member.ReturnType.FullName + "\"", - description - ); - } - - public static IOrderedCondition HaveReturnType(IObjectProvider types) - { IEnumerable Condition( IEnumerable methodMembers, Architecture architecture ) { - var typeList = types.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => - typeList.Any(type => methodMember.ReturnType.FullNameEquals(type.FullName)) - ) - .ToList(); - foreach (var failedObject in methodMemberList.Except(passedObjects)) - { - yield return new ConditionResult( - failedObject, - false, - "has return type \"" + failedObject.ReturnType.FullName + "\"" - ); - } - - foreach (var passedObject in passedObjects) + foreach (var methodMember in methodMembers) { - yield return new ConditionResult(passedObject, true); + if (typeList.Any(type => methodMember.ReturnTypeInstance.MatchesType(type))) + { + yield return new ConditionResult(methodMember, true); + } + else + { + yield return new ConditionResult( + methodMember, + false, + "has return type \"" + methodMember.ReturnType.FullName + "\"" + ); + } } } - var description = "have return type " + types.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition HaveReturnType( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveReturnType(types); - } - - public static IOrderedCondition HaveReturnType(IEnumerable types) - { - var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.ToString()).ToList(); - var description = - "have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - - bool Condition(MethodMember member) - { - return typeList.Any(type => member.ReturnTypeInstance.MatchesType(type)); - } - - return new SimpleCondition( - Condition, - member => "has return type \"" + member.ReturnType.FullName + "\"", - description + var typeDescription = string.Join( + " or ", + typeList.Select(type => $"\"{type.FullName}\"") ); + var description = typeList.Count == 0 + ? "have return type of no types (impossible)" + : $"have return type {typeDescription}"; + return new OrderedArchitectureCondition(Condition, description); } //Negations @@ -560,26 +210,6 @@ public static IOrderedCondition NotBeVirtual() ); } - public static IOrderedCondition NotBeCalledBy( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return NotBeCalledBy(types); - } - - public static IOrderedCondition NotBeCalledBy( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return NotBeCalledBy(types); - } - public static IOrderedCondition NotBeCalledBy( IObjectProvider objectProvider ) @@ -589,186 +219,32 @@ IEnumerable Condition( Architecture architecture ) { - var typeList = objectProvider.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - var failedObjects = methodMemberList - .Where(methodMember => methodMember.GetCallingTypes().Intersect(typeList).Any()) - .ToList(); - var failDescription = "is called by " + objectProvider.Description; - foreach (var failedObject in failedObjects) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in methodMemberList.Except(failedObjects)) - { - yield return new ConditionResult(passedObject, true); - } - } - - var description = "not be called by " + objectProvider.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition NotBeCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - var firstType = typeList.First(); - - IEnumerable Condition(IEnumerable methodMembers) - { - var methodMemberList = methodMembers.ToList(); - var failedObjects = methodMemberList - .Where(methodMember => methodMember.GetCallingTypes().Intersect(typeList).Any()) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = "is called by one of no types (always false)"; - } - else - { - failDescription = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "is called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - foreach (var failedObject in failedObjects) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in methodMemberList.Except(failedObjects)) - { - yield return new ConditionResult(passedObject, true); - } - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = "not be called by one of no types (always true)"; - } - else - { - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "not be called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new EnumerableCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition NotBeCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - var firstType = typeList.First(); - - IEnumerable Condition( - IEnumerable methodMembers, - Architecture architecture - ) - { - var archUnitTypeList = new List(); - foreach (var type in typeList) + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - try + if (!methodMember.GetCallingTypes().Any(isForbiddenType)) { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); + yield return new ConditionResult(methodMember, true); } - catch (TypeDoesNotExistInArchitecture) + else { - //ignore, can't have a dependency anyways - } - } - var methodMemberList = methodMembers.ToList(); - var failedObjects = methodMemberList - .Where(methodMember => - methodMember.GetCallingTypes().Intersect(archUnitTypeList).Any() - ) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = "is called by one of no types (always false)"; - } - else - { - failDescription = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "is called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" + yield return new ConditionResult( + methodMember, + false, + "is called by " + objectProvider.Description ); - } - - foreach (var failedObject in failedObjects) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in methodMemberList.Except(failedObjects)) - { - yield return new ConditionResult(passedObject, true); + } } } - string description; - if (typeList.IsNullOrEmpty()) - { - description = "not be called by one of no types (always true)"; - } - else - { - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "not be called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition NotHaveDependencyInMethodBodyTo( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return NotHaveDependencyInMethodBodyTo(types); - } - - public static IOrderedCondition NotHaveDependencyInMethodBodyTo( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return NotHaveDependencyInMethodBodyTo(types); + var description = objectProvider.FormatDescription( + "not be called by one of no types (always true)", + "not be called by", + "not be called by any" + ); + return new OrderedArchitectureCondition(Condition, description); } public static IOrderedCondition NotHaveDependencyInMethodBodyTo( @@ -780,292 +256,111 @@ IEnumerable Condition( Architecture architecture ) { - var typeList = objectProvider.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - var failedObjects = methodMemberList - .Where(methodMember => - methodMember - .GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(typeList) - .Any() - ) - .ToList(); - var failDescription = - "does have dependencies in method body to " + objectProvider.Description; - foreach (var failedObject in failedObjects) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in methodMemberList.Except(failedObjects)) + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - yield return new ConditionResult(passedObject, true); - } - } - - var description = - "not have dependencies in method body to " + objectProvider.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition NotHaveDependencyInMethodBodyTo( - IEnumerable types - ) - { - var typeList = types.ToList(); - var firstType = typeList.First(); - - IEnumerable Condition(IEnumerable methodMembers) - { - var methodMemberList = methodMembers.ToList(); - var failedObjects = methodMemberList - .Where(methodMember => - methodMember + if ( + !methodMember .GetBodyTypeMemberDependencies() .Select(dependency => dependency.Target) - .Intersect(typeList) - .Any() + .Any(isForbiddenType) ) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = - "does have dependencies in method body to one of no types (always false)"; - } - else - { - failDescription = typeList - .Where(type => !Equals(type, firstType)) - .Distinct() - .Aggregate( - "does have dependencies in method body to \"" - + firstType.FullName - + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" + { + yield return new ConditionResult(methodMember, true); + } + else + { + yield return new ConditionResult( + methodMember, + false, + "does have dependencies in method body to " + + objectProvider.Description ); + } } - - foreach (var failedObject in failedObjects) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in methodMemberList.Except(failedObjects)) - { - yield return new ConditionResult(passedObject, true); - } - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = - "not have dependencies in method body to one of no types (always true)"; - } - else - { - description = typeList - .Where(type => !Equals(type, firstType)) - .Distinct() - .Aggregate( - "not have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); } - return new EnumerableCondition( - Condition, - description - ).AsOrderedCondition(); + var description = objectProvider.FormatDescription( + "not have dependencies in method body to one of no types (always true)", + "not have dependencies in method body to", + "not have dependencies in method body to any" + ); + return new OrderedArchitectureCondition(Condition, description); } - public static IOrderedCondition NotHaveDependencyInMethodBodyTo( - IEnumerable types + public static IOrderedCondition NotHaveReturnType( + IObjectProvider objectProvider ) { - var typeList = types.ToList(); - var firstType = typeList.First(); - IEnumerable Condition( IEnumerable methodMembers, Architecture architecture ) { - var archUnitTypeList = new List(); - foreach (var type in typeList) + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - try + if (!isForbiddenType(methodMember.ReturnType)) { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); + yield return new ConditionResult(methodMember, true); } - catch (TypeDoesNotExistInArchitecture) + else { - //ignore, can't have a dependency anyways - } - } - var methodMemberList = methodMembers.ToList(); - var failedObjects = methodMemberList - .Where(methodMember => - methodMember - .GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(archUnitTypeList) - .Any() - ) - .ToList(); - string failDescription; - if (typeList.IsNullOrEmpty()) - { - failDescription = - "does have dependencies in method body to one of no types (always false)"; - } - else - { - failDescription = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "does have dependencies in method body to \"" - + firstType.FullName - + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" + yield return new ConditionResult( + methodMember, + false, + "has return type \"" + methodMember.ReturnType.FullName + "\"" ); - } - - foreach (var failedObject in failedObjects) - { - yield return new ConditionResult(failedObject, false, failDescription); - } - - foreach (var passedObject in methodMemberList.Except(failedObjects)) - { - yield return new ConditionResult(passedObject, true); + } } } - string description; - if (typeList.IsNullOrEmpty()) - { - description = - "not have dependencies in method body to one of no types (always true)"; - } - else - { - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "not have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition NotHaveReturnType( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return NotHaveReturnType(types); + var description = objectProvider.FormatDescription( + "not have return type of no types (always true)", + "not have return type", + "not have return type" + ); + return new OrderedArchitectureCondition(Condition, description); } - public static IOrderedCondition NotHaveReturnType(IEnumerable types) + public static IOrderedCondition NotHaveReturnType(IEnumerable types) { var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.FullName).ToList(); - var description = - "not have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - bool Condition(MethodMember member) - { - return typeList.All(type => !member.ReturnType.FullNameEquals(type.FullName)); - } - - return new SimpleCondition( - Condition, - member => "has return type \"" + member.ReturnType.FullName + "\"", - description - ); - } - - public static IOrderedCondition NotHaveReturnType( - IObjectProvider types - ) - { IEnumerable Condition( IEnumerable methodMembers, Architecture architecture ) { - var typeList = types.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - var passedObjects = methodMemberList - .Where(methodMember => - typeList.All(type => !methodMember.ReturnType.FullNameEquals(type.FullName)) - ) - .ToList(); - foreach (var failedObject in methodMemberList.Except(passedObjects)) + foreach (var methodMember in methodMembers) { - yield return new ConditionResult( - failedObject, - false, - "has return type \"" + failedObject.ReturnType.FullName + "\"" - ); - } - - foreach (var passedObject in passedObjects) - { - yield return new ConditionResult(passedObject, true); + if (typeList.All(type => !methodMember.ReturnTypeInstance.MatchesType(type))) + { + yield return new ConditionResult(methodMember, true); + } + else + { + yield return new ConditionResult( + methodMember, + false, + "has return type \"" + methodMember.ReturnType.FullName + "\"" + ); + } } } - var description = "not have return type " + types.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); - } - - public static IOrderedCondition NotHaveReturnType( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return NotHaveReturnType(types); - } - - public static IOrderedCondition NotHaveReturnType(IEnumerable types) - { - var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.ToString()).ToList(); - var description = - "not have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - - bool Condition(MethodMember member) - { - return typeList.All(type => !member.ReturnTypeInstance.MatchesType(type)); - } - - return new SimpleCondition( - Condition, - member => "has return type \"" + member.ReturnType.FullName + "\"", - description + var typeDescription = string.Join( + " or ", + typeList.Select(type => $"\"{type.FullName}\"") ); + var description = typeList.Count == 0 + ? "not have return type of no types (always true)" + : $"not have return type {typeDescription}"; + return new OrderedArchitectureCondition(Condition, description); } } } diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs index 1e576f656..1d1129478 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using ArchUnitNET.Domain; -using ArchUnitNET.Domain.Exceptions; using ArchUnitNET.Domain.Extensions; using ArchUnitNET.Fluent.Predicates; +using static ArchUnitNET.Domain.Extensions.EnumerableExtensions; namespace ArchUnitNET.Fluent.Syntax.Elements.Members.MethodMembers { @@ -23,304 +23,104 @@ public static IPredicate AreVirtual() return new SimplePredicate(member => member.IsVirtual, "are virtual"); } - public static IPredicate AreCalledBy( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return AreCalledBy(types); - } - - public static IPredicate AreCalledBy(Type firstType, params Type[] moreTypes) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return AreCalledBy(types); - } - public static IPredicate AreCalledBy(IObjectProvider objectProvider) { - IEnumerable Condition( - IEnumerable ruleTypes, - Architecture architecture - ) - { - var types = objectProvider.GetObjects(architecture); - return ruleTypes.Where(type => type.GetCallingTypes().Intersect(types).Any()); - } - - var description = "are called by " + objectProvider.Description; - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate AreCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - - IEnumerable Condition(IEnumerable ruleTypes) - { - return ruleTypes.Where(type => type.GetCallingTypes().Intersect(typeList).Any()); - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = "are called by one of no types (always false)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "are called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new EnumerablePredicate(Condition, description); - } - - public static IPredicate AreCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - - IEnumerable Condition( + IEnumerable Filter( IEnumerable ruleTypes, Architecture architecture ) { - var archUnitTypeList = new List(); - foreach (var type in typeList) - { - try - { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); - } - catch (TypeDoesNotExistInArchitecture) - { - //ignore, can't have a dependency anyways - } - } - return ruleTypes.Where(type => - type.GetCallingTypes().Intersect(archUnitTypeList).Any() + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + return ruleTypes.Where(methodMember => + methodMember.GetCallingTypes().Any(isRequiredType) ); } - string description; - if (typeList.IsNullOrEmpty()) - { - description = "are called by one of no types (always false)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "are called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate HaveDependencyInMethodBodyTo( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveDependencyInMethodBodyTo(types); - } - - public static IPredicate HaveDependencyInMethodBodyTo( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveDependencyInMethodBodyTo(types); + var description = objectProvider.FormatDescription( + "are called by one of no types (impossible)", + "are called by", + "are called by any" + ); + return new ArchitecturePredicate(Filter, description); } public static IPredicate HaveDependencyInMethodBodyTo( IObjectProvider objectProvider ) { - IEnumerable Condition( + IEnumerable Filter( IEnumerable ruleTypes, Architecture architecture ) { - var types = objectProvider.GetObjects(architecture); - return ruleTypes.Where(type => - type.GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(types) - .Any() + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() ); - } - - var description = "have dependencies in method body to " + objectProvider.Description; - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate HaveDependencyInMethodBodyTo( - IEnumerable types - ) - { - var typeList = types.ToList(); - - IEnumerable Condition(IEnumerable ruleTypes) - { - return ruleTypes.Where(type => - type.GetBodyTypeMemberDependencies() + return ruleTypes.Where(methodMember => + methodMember + .GetBodyTypeMemberDependencies() .Select(dependency => dependency.Target) - .Intersect(typeList) - .Any() + .Any(isRequiredType) ); } - string description; - if (typeList.IsNullOrEmpty()) - { - description = "have dependencies in method body to one of no types (always false)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new EnumerablePredicate(Condition, description); + var description = objectProvider.FormatDescription( + "have dependencies in method body to one of no types (impossible)", + "have dependencies in method body to", + "have dependencies in method body to any" + ); + return new ArchitecturePredicate(Filter, description); } - public static IPredicate HaveDependencyInMethodBodyTo(IEnumerable types) + public static IPredicate HaveReturnType( + IObjectProvider objectProvider + ) { - var typeList = types.ToList(); - - IEnumerable Condition( - IEnumerable ruleTypes, + IEnumerable Filter( + IEnumerable methodMembers, Architecture architecture ) { - var archUnitTypeList = new List(); - foreach (var type in typeList) - { - try - { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); - } - catch (TypeDoesNotExistInArchitecture) - { - //ignore, can't have a dependency anyways - } - } - return ruleTypes.Where(type => - type.GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(archUnitTypeList) - .Any() + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + return methodMembers.Where(methodMember => + isRequiredType(methodMember.ReturnType) ); } - string description; - if (typeList.IsNullOrEmpty()) - { - description = "have dependencies in method body to one of no types (always false)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate HaveReturnType( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveReturnType(types); + var description = objectProvider.FormatDescription( + "have return type of no types (impossible)", + "have return type", + "have return type" + ); + return new ArchitecturePredicate(Filter, description); } - public static IPredicate HaveReturnType(IEnumerable types) + public static IPredicate HaveReturnType(IEnumerable types) { var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.FullName).ToList(); - var description = - "have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - - return new SimplePredicate( - member => typeList.Any(type => member.ReturnType.FullNameEquals(type.FullName)), - description - ); - } - public static IPredicate HaveReturnType(IObjectProvider types) - { - IEnumerable Condition( + IEnumerable Filter( IEnumerable methodMembers, Architecture architecture ) { - var typeList = types.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - return methodMemberList.Where(methodMember => - typeList.Any(type => methodMember.ReturnType.FullNameEquals(type.FullName)) + return methodMembers.Where(methodMember => + typeList.Any(type => methodMember.ReturnTypeInstance.MatchesType(type)) ); } - var description = "have return type " + types.Description; - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate HaveReturnType( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return HaveReturnType(types); - } - - public static IPredicate HaveReturnType(IEnumerable types) - { - var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.ToString()).ToList(); - var description = - "have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - - return new SimplePredicate( - member => typeList.Any(type => member.ReturnTypeInstance.MatchesType(type)), - description + var typeDescription = string.Join( + " or ", + typeList.Select(type => $"\"{type.FullName}\"") ); + var description = typeList.Count == 0 + ? "have return type of no types (impossible)" + : $"have return type {typeDescription}"; + return new ArchitecturePredicate(Filter, description); } //Negations @@ -342,311 +142,105 @@ public static IPredicate AreNotVirtual() } public static IPredicate AreNotCalledBy( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return AreNotCalledBy(types); - } - - public static IPredicate AreNotCalledBy( - Type firstType, - params Type[] moreTypes + IObjectProvider objectProvider ) { - var types = new List { firstType }; - types.AddRange(moreTypes); - return AreNotCalledBy(types); - } - - public static IPredicate AreNotCalledBy(IObjectProvider objectProvider) - { - IEnumerable Condition( - IEnumerable ruleTypes, - Architecture architecture - ) - { - var types = objectProvider.GetObjects(architecture); - return ruleTypes.Where(type => !type.GetCallingTypes().Intersect(types).Any()); - } - - var description = "are not called by " + objectProvider.Description; - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate AreNotCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - - IEnumerable Condition(IEnumerable ruleTypes) - { - return ruleTypes.Where(type => !type.GetCallingTypes().Intersect(typeList).Any()); - } - - string description; - if (typeList.IsNullOrEmpty()) - { - description = "are not called by one of no types (always true)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "are not called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new EnumerablePredicate(Condition, description); - } - - public static IPredicate AreNotCalledBy(IEnumerable types) - { - var typeList = types.ToList(); - - IEnumerable Condition( + IEnumerable Filter( IEnumerable ruleTypes, Architecture architecture ) { - var archUnitTypeList = new List(); - foreach (var type in typeList) - { - try - { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); - } - catch (TypeDoesNotExistInArchitecture) - { - //ignore, can't have a dependency anyways - } - } - return ruleTypes.Where(type => - !type.GetCallingTypes().Intersect(archUnitTypeList).Any() + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + return ruleTypes.Where(methodMember => + !methodMember.GetCallingTypes().Any(isForbiddenType) ); } - string description; - if (typeList.IsNullOrEmpty()) - { - description = "are not called by one of no types (always false)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "are not called by \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate DoNotHaveDependencyInMethodBodyTo( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return DoNotHaveDependencyInMethodBodyTo(types); - } - - public static IPredicate DoNotHaveDependencyInMethodBodyTo( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return DoNotHaveDependencyInMethodBodyTo(types); + var description = objectProvider.FormatDescription( + "are not called by one of no types (always true)", + "are not called by", + "are not called by any" + ); + return new ArchitecturePredicate(Filter, description); } public static IPredicate DoNotHaveDependencyInMethodBodyTo( IObjectProvider objectProvider ) { - IEnumerable Condition( + IEnumerable Filter( IEnumerable ruleTypes, Architecture architecture ) { - var types = objectProvider.GetObjects(architecture); - return ruleTypes.Where(type => - !type.GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(types) - .Any() + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() ); - } - - var description = - "do not have dependencies in method body to " + objectProvider.Description; - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate DoNotHaveDependencyInMethodBodyTo( - IEnumerable types - ) - { - var typeList = types.ToList(); - - IEnumerable Condition(IEnumerable ruleTypes) - { - return ruleTypes.Where(type => - !type.GetBodyTypeMemberDependencies() + return ruleTypes.Where(methodMember => + !methodMember + .GetBodyTypeMemberDependencies() .Select(dependency => dependency.Target) - .Intersect(typeList) - .Any() + .Any(isForbiddenType) ); } - string description; - if (typeList.IsNullOrEmpty()) - { - description = - "do not have dependencies in method body to one of no types (always true)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => !type.Equals(firstType)) - .Distinct() - .Aggregate( - "do not have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new EnumerablePredicate(Condition, description); + var description = objectProvider.FormatDescription( + "do not have dependencies in method body to one of no types (always true)", + "do not have dependencies in method body to", + "do not have dependencies in method body to any" + ); + return new ArchitecturePredicate(Filter, description); } - public static IPredicate DoNotHaveDependencyInMethodBodyTo( - IEnumerable types + public static IPredicate DoNotHaveReturnType( + IObjectProvider objectProvider ) { - var typeList = types.ToList(); - - IEnumerable Condition( - IEnumerable ruleTypes, + IEnumerable Filter( + IEnumerable methodMembers, Architecture architecture ) { - var archUnitTypeList = new List(); - foreach (var type in typeList) - { - try - { - var archUnitType = architecture.GetITypeOfType(type); - archUnitTypeList.Add(archUnitType); - } - catch (TypeDoesNotExistInArchitecture) - { - //ignore, can't have a dependency anyways - } - } - return ruleTypes.Where(type => - !type.GetBodyTypeMemberDependencies() - .Select(dependency => dependency.Target) - .Intersect(archUnitTypeList) - .Any() + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + return methodMembers.Where(methodMember => + !isForbiddenType(methodMember.ReturnType) ); } - string description; - if (typeList.IsNullOrEmpty()) - { - description = - "do not have dependencies in method body to one of no types (always true)"; - } - else - { - var firstType = typeList.First(); - description = typeList - .Where(type => type != firstType) - .Distinct() - .Aggregate( - "do not have dependencies in method body to \"" + firstType.FullName + "\"", - (current, type) => current + " or \"" + type.FullName + "\"" - ); - } - - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate DoNotHaveReturnType( - IType firstType, - params IType[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return DoNotHaveReturnType(types); + var description = objectProvider.FormatDescription( + "do not have return type of no types (always true)", + "do not have return type", + "do not have return type" + ); + return new ArchitecturePredicate(Filter, description); } - public static IPredicate DoNotHaveReturnType(IEnumerable types) + public static IPredicate DoNotHaveReturnType(IEnumerable types) { var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.FullName).ToList(); - var description = - "do not have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - - return new SimplePredicate( - member => typeList.Any(type => !member.ReturnType.FullNameEquals(type.FullName)), - description - ); - } - public static IPredicate DoNotHaveReturnType(IObjectProvider types) - { - IEnumerable Condition( + IEnumerable Filter( IEnumerable methodMembers, Architecture architecture ) { - var typeList = types.GetObjects(architecture).ToList(); - var methodMemberList = methodMembers.ToList(); - return methodMemberList.Where(methodMember => - typeList.All(type => !methodMember.ReturnType.FullNameEquals(type.FullName)) + return methodMembers.Where(methodMember => + typeList.All(type => !methodMember.ReturnTypeInstance.MatchesType(type)) ); } - var description = "do not have return type " + types.Description; - return new ArchitecturePredicate(Condition, description); - } - - public static IPredicate DoNotHaveReturnType( - Type firstType, - params Type[] moreTypes - ) - { - var types = new List { firstType }; - types.AddRange(moreTypes); - return DoNotHaveReturnType(types); - } - - public static IPredicate DoNotHaveReturnType(IEnumerable types) - { - var typeList = types.ToList(); - var typeStringList = typeList.Select(type => type.ToString()).ToList(); - var description = - "do not have return type \"" + string.Join("\" or \"", typeStringList) + "\""; - - return new SimplePredicate( - member => typeList.All(type => !member.ReturnTypeInstance.MatchesType(type)), - description + var typeDescription = string.Join( + " or ", + typeList.Select(type => $"\"{type.FullName}\"") ); + var description = typeList.Count == 0 + ? "do not have return type of no types (always true)" + : $"do not have return type {typeDescription}"; + return new ArchitecturePredicate(Filter, description); } } } diff --git a/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs b/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs index c65e2e497..cfb0795c0 100644 --- a/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs +++ b/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs @@ -165,6 +165,16 @@ public class TypeAssemblyTestHelper : AssemblyTestHelper public Type ClassWithOtherRegularClassReturnTypeSystemType = typeof(ClassWithOtherRegularClassReturnType); + // Generic return type test classes + public Class GenericClassOneArg; + public Type GenericClassOneArgSystemType = typeof(GenericClass<>); + + public Class GenericClassTwoArg; + public Type GenericClassTwoArgSystemType = typeof(GenericClass<,>); + + public Class ClassWithGenericReturnType; + public Type ClassWithGenericReturnTypeSystemType = typeof(ClassWithGenericReturnType); + // Individual members public IMember StaticField; public IMember NonStaticField; @@ -187,6 +197,9 @@ public class TypeAssemblyTestHelper : AssemblyTestHelper public MethodMember ClassWithNonVirtualMethodConstructor; public MethodMember MethodReturningRegularClass; public MethodMember MethodReturningOtherRegularClass; + public MethodMember MethodReturningGenericClass; + public MethodMember MethodReturningGenericClassWithOtherArg; + public MethodMember MethodReturningTwoArgGenericClass; public TypeAssemblyTestHelper() { @@ -291,6 +304,13 @@ public TypeAssemblyTestHelper() typeof(ClassWithOtherRegularClassReturnType) ); + // Generic return type test classes + GenericClassOneArg = Architecture.GetClassOfType(typeof(GenericClass<>)); + GenericClassTwoArg = Architecture.GetClassOfType(typeof(GenericClass<,>)); + ClassWithGenericReturnType = Architecture.GetClassOfType( + typeof(ClassWithGenericReturnType) + ); + // Method members (MethodMember type) VirtualMethod = ClassWithVirtualMethod.GetMethodMembersWithName("VirtualMethod()").First(); OtherVirtualMethod = OtherClassWithVirtualMethod @@ -317,5 +337,14 @@ public TypeAssemblyTestHelper() MethodReturningOtherRegularClass = ClassWithOtherRegularClassReturnType .GetMethodMembersWithName("MethodReturningOtherRegularClass()") .First(); + MethodReturningGenericClass = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningGenericClass()") + .First(); + MethodReturningGenericClassWithOtherArg = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningGenericClassWithOtherArg()") + .First(); + MethodReturningTwoArgGenericClass = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningTwoArgGenericClass()") + .First(); } } diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/MatchGenericReturnTypesTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/MatchGenericReturnTypesTests.cs deleted file mode 100644 index 84001555c..000000000 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/MatchGenericReturnTypesTests.cs +++ /dev/null @@ -1,218 +0,0 @@ -using ArchUnitNET.Domain; -using ArchUnitNET.Loader; -using ArchUnitNET.xUnit; -using Xunit; -using static ArchUnitNET.Fluent.ArchRuleDefinition; - -namespace ArchUnitNETTests.Fluent.Syntax.Elements -{ - public class MatchGenericReturnTypesTests - { - private static readonly Architecture Architecture = new ArchLoader() - .LoadAssemblies(System.Reflection.Assembly.Load("ArchUnitNETTests")) - .Build(); - - [Fact] - public void OneGenericParameter() - { - MethodMembers() - .That() - .AreDeclaredIn(typeof(OneGenericReturnTypeExample)) - .And() - .HaveName("CorrectGenericArgument()") - .Should() - .Exist() - .AndShould() - .HaveReturnType(typeof(ExampleGenericClass<>)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(OneGenericReturnTypeExample)) - .And() - .HaveName("WrongGenericArgument()") - .Should() - .Exist() - .AndShould() - .HaveReturnType(typeof(ExampleGenericClass<>)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(OneGenericReturnTypeExample)) - .And() - .HaveNameContaining("WrongReturnType") - .Should() - .Exist() - .AndShould() - .NotHaveReturnType(typeof(ExampleGenericClass<>)) - .Check(Architecture); - } - - [Fact] - public void TwoGenericParameters() - { - MethodMembers() - .That() - .AreDeclaredIn(typeof(TwoGenericReturnTypesExample)) - .And() - .HaveName("CorrectGenericArgument()") - .Should() - .Exist() - .AndShould() - .HaveReturnType(typeof(ExampleGenericClass<,>)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(TwoGenericReturnTypesExample)) - .And() - .HaveName("WrongGenericArgument()") - .Should() - .Exist() - .AndShould() - .HaveReturnType(typeof(ExampleGenericClass<,>)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(TwoGenericReturnTypesExample)) - .And() - .HaveNameContaining("WrongReturnType") - .Should() - .Exist() - .AndShould() - .NotHaveReturnType(typeof(ExampleGenericClass<,>)) - .Check(Architecture); - } - - [Fact] - public void OneGenericArgument() - { - MethodMembers() - .That() - .AreDeclaredIn(typeof(OneGenericReturnTypeExample)) - .And() - .HaveName("CorrectGenericArgument()") - .Should() - .Exist() - .AndShould() - .HaveReturnType(typeof(ExampleGenericClass)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(OneGenericReturnTypeExample)) - .And() - .HaveName("WrongGenericArgument()") - .Should() - .Exist() - .AndShould() - .NotHaveReturnType(typeof(ExampleGenericClass)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(OneGenericReturnTypeExample)) - .And() - .HaveNameContaining("WrongReturnType") - .Should() - .Exist() - .AndShould() - .NotHaveReturnType(typeof(ExampleGenericClass)) - .Check(Architecture); - } - - [Fact] - public void TwoGenericArguments() - { - MethodMembers() - .That() - .AreDeclaredIn(typeof(TwoGenericReturnTypesExample)) - .And() - .HaveName("CorrectGenericArgument()") - .Should() - .Exist() - .AndShould() - .HaveReturnType(typeof(ExampleGenericClass)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(TwoGenericReturnTypesExample)) - .And() - .HaveName("WrongGenericArgument()") - .Should() - .Exist() - .AndShould() - .NotHaveReturnType(typeof(ExampleGenericClass)) - .Check(Architecture); - MethodMembers() - .That() - .AreDeclaredIn(typeof(TwoGenericReturnTypesExample)) - .And() - .HaveNameContaining("WrongReturnType") - .Should() - .Exist() - .AndShould() - .NotHaveReturnType(typeof(ExampleGenericClass)) - .Check(Architecture); - } - } - - // ReSharper disable All - class ExampleGenericClass { } - - class ExampleGenericClass { } - - class ExampleArgument { } - - class OneGenericReturnTypeExample - { - public ExampleGenericClass CorrectGenericArgument() - { - return new ExampleGenericClass(); - } - - public ExampleGenericClass WrongGenericArgument() - { - return new ExampleGenericClass(); - } - - public ExampleGenericClass WrongReturnType1() - { - return new ExampleGenericClass(); - } - - public void WrongReturnType2() - { - return; - } - - public bool WrongReturnType3() - { - return true; - } - } - - class TwoGenericReturnTypesExample - { - public ExampleGenericClass CorrectGenericArgument() - { - return new ExampleGenericClass(); - } - - public ExampleGenericClass WrongGenericArgument() - { - return new ExampleGenericClass(); - } - - public ExampleGenericClass WrongReturnType1() - { - return new ExampleGenericClass(); - } - - public void WrongReturnType2() - { - return; - } - - public bool WrongReturnType3() - { - return true; - } - } -} diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs index 05372ba90..4971d9ffb 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Threading.Tasks; using ArchUnitNET.Domain; +using ArchUnitNET.Domain.Exceptions; using ArchUnitNETTests.AssemblyTestHelper; +using TypeNamespace; using Xunit; using static ArchUnitNET.Fluent.ArchRuleDefinition; @@ -189,10 +191,8 @@ public async Task BeCalledByTest() should = MethodMembers().That().Are(helper.CalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - // TODO: Empty IEnumerable/ crashes with InvalidOperationException - // (.First() on empty list) — uncomment when AssertException supports lazy evaluation - // should.BeCalledBy(new List()).AssertException(helper); - // should.BeCalledBy(new List()).AssertException(helper); + should.BeCalledBy(new List()).AssertOnlyViolations(helper); + should.BeCalledBy(new List()).AssertOnlyViolations(helper); helper.AddSnapshotSubHeader("Predicates"); should.Be(MethodMembers().That().AreCalledBy(new List())).AssertOnlyViolations(helper); @@ -202,10 +202,10 @@ public async Task BeCalledByTest() should = MethodMembers().That().Are(helper.CalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - should.BeCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertOnlyViolations(helper); + should.BeCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertException(helper); helper.AddSnapshotSubHeader("Predicates"); - should.Be(MethodMembers().That().AreCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().AreCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertException(helper); helper.AddSnapshotHeader("Multiple inputs"); MethodMembers().That().Are(helper.CalledMethod, helper.CalledMethod1).Should().BeCalledBy(helper.MethodDependencyClass).AssertNoViolations(helper); @@ -272,10 +272,8 @@ public async Task NotBeCalledByTest() should = MethodMembers().That().Are(helper.CalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - // TODO: Empty IEnumerable/ crashes with InvalidOperationException - // (.First() on empty list) — uncomment when AssertException supports lazy evaluation - // should.NotBeCalledBy(new List()).AssertException(helper); - // should.NotBeCalledBy(new List()).AssertException(helper); + should.NotBeCalledBy(new List()).AssertNoViolations(helper); + should.NotBeCalledBy(new List()).AssertNoViolations(helper); helper.AddSnapshotSubHeader("Predicates"); should.Be(MethodMembers().That().AreNotCalledBy(new List())).AssertNoViolations(helper); @@ -285,10 +283,10 @@ public async Task NotBeCalledByTest() should = MethodMembers().That().Are(helper.CalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - should.NotBeCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertNoViolations(helper); + should.NotBeCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertException(helper); helper.AddSnapshotSubHeader("Predicates"); - should.Be(MethodMembers().That().AreNotCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertNoViolations(helper); + should.Be(MethodMembers().That().AreNotCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertException(helper); helper.AddSnapshotHeader("Multiple inputs"); MethodMembers().That().Are(helper.MethodWithoutDependencies, helper.MethodCallingCalledMethod).Should().NotBeCalledBy(helper.MethodDependencyClass).AssertNoViolations(helper); @@ -355,10 +353,8 @@ public async Task HaveDependencyInMethodBodyToTest() should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - // TODO: Empty IEnumerable/ crashes with InvalidOperationException - // (.First() on empty list) — uncomment when AssertException supports lazy evaluation - // should.HaveDependencyInMethodBodyTo(new List()).AssertException(helper); - // should.HaveDependencyInMethodBodyTo(new List()).AssertException(helper); + should.HaveDependencyInMethodBodyTo(new List()).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(new List()).AssertOnlyViolations(helper); helper.AddSnapshotSubHeader("Predicates"); should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List())).AssertOnlyViolations(helper); @@ -368,10 +364,10 @@ public async Task HaveDependencyInMethodBodyToTest() should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - should.HaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertException(helper); helper.AddSnapshotSubHeader("Predicates"); - should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertException(helper); helper.AddSnapshotHeader("Multiple inputs"); MethodMembers().That().Are(helper.MethodCallingCalledMethod, helper.AnotherMethodCallingCalledMethod).Should().HaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertNoViolations(helper); @@ -438,10 +434,8 @@ public async Task NotHaveDependencyInMethodBodyToTest() should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - // TODO: Empty IEnumerable/ crashes with InvalidOperationException - // (.First() on empty list) — uncomment when AssertException supports lazy evaluation - // should.NotHaveDependencyInMethodBodyTo(new List()).AssertException(helper); - // should.NotHaveDependencyInMethodBodyTo(new List()).AssertException(helper); + should.NotHaveDependencyInMethodBodyTo(new List()).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List()).AssertNoViolations(helper); helper.AddSnapshotSubHeader("Predicates"); should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List())).AssertNoViolations(helper); @@ -451,10 +445,10 @@ public async Task NotHaveDependencyInMethodBodyToTest() should = MethodMembers().That().Are(helper.MethodCallingCalledMethod).Should(); helper.AddSnapshotSubHeader("Conditions"); - should.NotHaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) }).AssertException(helper); helper.AddSnapshotSubHeader("Predicates"); - should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveDependencyInMethodBodyTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertException(helper); helper.AddSnapshotHeader("Multiple inputs"); MethodMembers().That().Are(helper.MethodWithoutDependencies, helper.CalledMethod).Should().NotHaveDependencyInMethodBodyTo(helper.OtherCallingClass).AssertNoViolations(helper); @@ -521,6 +515,48 @@ public async Task HaveReturnTypeTest() MethodMembers().That().Are(helper.MethodReturningRegularClass, helper.MethodReturningOtherRegularClass).Should().HaveReturnType(helper.RegularClass).AssertAnyViolations(helper); MethodMembers().That().Are(helper.MethodReturningRegularClass, helper.MethodReturningOtherRegularClass).Should().HaveReturnType(helper.RegularClass, helper.OtherRegularClass).AssertNoViolations(helper); + helper.AddSnapshotHeader("Open generic System.Type matches closed generic IType"); + should = MethodMembers().That().Are(helper.MethodReturningGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(typeof(GenericClass<>)).AssertNoViolations(helper); + should.HaveReturnType(new List { typeof(GenericClass<>) }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(typeof(GenericClass<>))).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { typeof(GenericClass<>) })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Specific closed generic System.Type matches exact return type"); + should = MethodMembers().That().Are(helper.MethodReturningGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(typeof(GenericClass)).AssertNoViolations(helper); + should.HaveReturnType(new List { typeof(GenericClass) }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(typeof(GenericClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { typeof(GenericClass) })).AssertNoViolations(helper); + + helper.AddSnapshotHeader("Specific closed generic System.Type rejects wrong generic argument"); + should = MethodMembers().That().Are(helper.MethodReturningGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(typeof(GenericClass)).AssertOnlyViolations(helper); + should.HaveReturnType(new List { typeof(GenericClass) }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(typeof(GenericClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().HaveReturnType(new List { typeof(GenericClass) })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Two-arg open generic System.Type matches two-arg closed generic"); + should = MethodMembers().That().Are(helper.MethodReturningTwoArgGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.HaveReturnType(typeof(GenericClass<,>)).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().HaveReturnType(typeof(GenericClass<,>))).AssertNoViolations(helper); + await helper.AssertSnapshotMatches(); } @@ -574,18 +610,50 @@ public async Task DoNotHaveReturnTypeTest() should.NotHaveReturnType(helper.OtherRegularClassSystemType, helper.RegularClassSystemType).AssertOnlyViolations(helper); should.NotHaveReturnType(new List { helper.OtherRegularClassSystemType, helper.RegularClassSystemType }).AssertOnlyViolations(helper); - // DoNotHaveReturnType predicate uses .Any(type => !match) for IEnumerable — passes if ANY type doesn't match - // With {OtherRegularClass, RegularClass}: OtherRegularClass doesn't match (true) => Any = true => passes - // BUT: IEnumerable and IObjectProvider overloads use .All(type => !match) — fails if ANY type matches + // DoNotHaveReturnType predicate now uses consistent set-based semantics — + // passes only if return type is NOT in the provided set helper.AddSnapshotSubHeader("Predicates"); - should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClass, helper.RegularClass)).AssertNoViolations(helper); - should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClass, helper.RegularClass })).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClass, helper.RegularClass)).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClass, helper.RegularClass })).AssertOnlyViolations(helper); should.Be(MethodMembers().That().DoNotHaveReturnType(helper.OtherRegularClassSystemType, helper.RegularClassSystemType)).AssertOnlyViolations(helper); should.Be(MethodMembers().That().DoNotHaveReturnType(new List { helper.OtherRegularClassSystemType, helper.RegularClassSystemType })).AssertOnlyViolations(helper); helper.AddSnapshotHeader("Multiple inputs"); MethodMembers().That().Are(helper.MethodReturningRegularClass, helper.MethodReturningOtherRegularClass).Should().NotHaveReturnType(helper.RegularClass).AssertAnyViolations(helper); + helper.AddSnapshotHeader("Open generic System.Type matches closed generic for negation"); + should = MethodMembers().That().Are(helper.MethodReturningGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveReturnType(typeof(GenericClass<>)).AssertOnlyViolations(helper); + should.NotHaveReturnType(new List { typeof(GenericClass<>) }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveReturnType(typeof(GenericClass<>))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { typeof(GenericClass<>) })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Specific closed generic System.Type for negation"); + should = MethodMembers().That().Are(helper.MethodReturningGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveReturnType(typeof(GenericClass)).AssertOnlyViolations(helper); + should.NotHaveReturnType(new List { typeof(GenericClass) }).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveReturnType(typeof(GenericClass))).AssertOnlyViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { typeof(GenericClass) })).AssertOnlyViolations(helper); + + helper.AddSnapshotHeader("Wrong closed generic System.Type is not a violation for negation"); + should = MethodMembers().That().Are(helper.MethodReturningGenericClass).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.NotHaveReturnType(typeof(GenericClass)).AssertNoViolations(helper); + should.NotHaveReturnType(new List { typeof(GenericClass) }).AssertNoViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().DoNotHaveReturnType(typeof(GenericClass))).AssertNoViolations(helper); + should.Be(MethodMembers().That().DoNotHaveReturnType(new List { typeof(GenericClass) })).AssertNoViolations(helper); + await helper.AssertSnapshotMatches(); } diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt index 1f4f27eb7..ead6cda0b 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt @@ -14,7 +14,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Called Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: @@ -46,7 +46,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Called Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: @@ -86,11 +86,11 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: False Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by any Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" @@ -133,12 +133,12 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by any Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" @@ -164,25 +164,25 @@ Message: ----- Conditions ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: @@ -190,25 +190,25 @@ All Evaluations passed ----- Predicates ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: @@ -218,23 +218,41 @@ All Evaluations passed ----- Conditions ----- +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible) +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by + + + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible) +Result: False +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by +Message: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by + + + ----- Predicates ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false) +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible) Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false)" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false) +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible) Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (always false)" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (always false) +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) @@ -243,24 +261,12 @@ Message: ----- Conditions ----- Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "AttributeNamespace.ClassWithoutAttributes" -Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by "AttributeNamespace.ClassWithoutAttributes" -Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by "AttributeNamespace.ClassWithoutAttributes"" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by "AttributeNamespace.ClassWithoutAttributes" - - +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ----- Predicates ----- Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "AttributeNamespace.ClassWithoutAttributes" -Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by "AttributeNamespace.ClassWithoutAttributes" -Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "AttributeNamespace.ClassWithoutAttributes"" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by "AttributeNamespace.ClassWithoutAttributes" - - +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ===== Multiple inputs ===== diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt index 976c4d30d..78c02b29d 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeMethodMembersThatTest.verified.txt @@ -10,10 +10,10 @@ All Evaluations passed Query: Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be method members that are constructors Result: False -Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void TypeNamespace.RegularClass::.ctor()" or "System.Void TypeNamespace.OtherRegularClass::.ctor()" or "System.Void TypeNamespace.ClassWithProperty::.ctor()" or "System.Void TypeNamespace.ClassWithField::.ctor()" or "System.Void TypeNamespace.ClassWithMethod::.ctor()" or "System.Void TypeNamespace.ClassWithAllMembers::.ctor()" or "System.Void TypeNamespace.ClassWithoutMembers::.ctor()" or "System.Void TypeNamespace.OuterClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB::.ctor()" or "System.Void TypeNamespace.NonNestedClass::.ctor()" or "System.Void TypeNamespace.ClassImplementingInterface::.ctor()" or "System.Void TypeNamespace.ClassNotImplementingInterface::.ctor()" or "System.Void TypeNamespace.BaseClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherBaseClassForAssign::.ctor()" or "System.Void TypeNamespace.DerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherDerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.UnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherUnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.ClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithNonStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithReadOnlyField::.ctor()" or "System.Void TypeNamespace.ClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.ClassWithInitOnlyProperty::.ctor()" or "System.Void TypeNamespace.ClassWithGetOnlyProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.cctor()" or "System.Void TypeNamespace.ClassWithStaticMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithStringReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithIntReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.OuterClassA/InnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassA/OtherInnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB/InnerClassB::.ctor()" +Description: System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void TypeNamespace.RegularClass::.ctor()" or "System.Void TypeNamespace.OtherRegularClass::.ctor()" or "System.Void TypeNamespace.ClassWithProperty::.ctor()" or "System.Void TypeNamespace.ClassWithField::.ctor()" or "System.Void TypeNamespace.ClassWithMethod::.ctor()" or "System.Void TypeNamespace.ClassWithAllMembers::.ctor()" or "System.Void TypeNamespace.ClassWithoutMembers::.ctor()" or "System.Void TypeNamespace.OuterClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB::.ctor()" or "System.Void TypeNamespace.NonNestedClass::.ctor()" or "System.Void TypeNamespace.ClassImplementingInterface::.ctor()" or "System.Void TypeNamespace.ClassNotImplementingInterface::.ctor()" or "System.Void TypeNamespace.BaseClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherBaseClassForAssign::.ctor()" or "System.Void TypeNamespace.DerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherDerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.UnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherUnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.ClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithNonStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithReadOnlyField::.ctor()" or "System.Void TypeNamespace.ClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.ClassWithInitOnlyProperty::.ctor()" or "System.Void TypeNamespace.ClassWithGetOnlyProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.cctor()" or "System.Void TypeNamespace.ClassWithStaticMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithStringReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithIntReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.GenericClass`1::.ctor()" or "System.Void TypeNamespace.GenericClass`2::.ctor()" or "System.Void TypeNamespace.ClassWithGenericReturnType::.ctor()" or "System.Void TypeNamespace.OuterClassA/InnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassA/OtherInnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB/InnerClassB::.ctor()" Message: "Method members that are "System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod()" should be method members that are constructors" failed: - System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void TypeNamespace.RegularClass::.ctor()" or "System.Void TypeNamespace.OtherRegularClass::.ctor()" or "System.Void TypeNamespace.ClassWithProperty::.ctor()" or "System.Void TypeNamespace.ClassWithField::.ctor()" or "System.Void TypeNamespace.ClassWithMethod::.ctor()" or "System.Void TypeNamespace.ClassWithAllMembers::.ctor()" or "System.Void TypeNamespace.ClassWithoutMembers::.ctor()" or "System.Void TypeNamespace.OuterClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB::.ctor()" or "System.Void TypeNamespace.NonNestedClass::.ctor()" or "System.Void TypeNamespace.ClassImplementingInterface::.ctor()" or "System.Void TypeNamespace.ClassNotImplementingInterface::.ctor()" or "System.Void TypeNamespace.BaseClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherBaseClassForAssign::.ctor()" or "System.Void TypeNamespace.DerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherDerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.UnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherUnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.ClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithNonStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithReadOnlyField::.ctor()" or "System.Void TypeNamespace.ClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.ClassWithInitOnlyProperty::.ctor()" or "System.Void TypeNamespace.ClassWithGetOnlyProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.cctor()" or "System.Void TypeNamespace.ClassWithStaticMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithStringReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithIntReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.OuterClassA/InnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassA/OtherInnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB/InnerClassB::.ctor()" + System.Void TypeNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void TypeNamespace.RegularClass::.ctor()" or "System.Void TypeNamespace.OtherRegularClass::.ctor()" or "System.Void TypeNamespace.ClassWithProperty::.ctor()" or "System.Void TypeNamespace.ClassWithField::.ctor()" or "System.Void TypeNamespace.ClassWithMethod::.ctor()" or "System.Void TypeNamespace.ClassWithAllMembers::.ctor()" or "System.Void TypeNamespace.ClassWithoutMembers::.ctor()" or "System.Void TypeNamespace.OuterClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB::.ctor()" or "System.Void TypeNamespace.NonNestedClass::.ctor()" or "System.Void TypeNamespace.ClassImplementingInterface::.ctor()" or "System.Void TypeNamespace.ClassNotImplementingInterface::.ctor()" or "System.Void TypeNamespace.BaseClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherBaseClassForAssign::.ctor()" or "System.Void TypeNamespace.DerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherDerivedClassForAssign::.ctor()" or "System.Void TypeNamespace.UnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.OtherUnrelatedClassForAssign::.ctor()" or "System.Void TypeNamespace.ClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithNonStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithReadOnlyField::.ctor()" or "System.Void TypeNamespace.ClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithWritableProperty::.ctor()" or "System.Void TypeNamespace.ClassWithInitOnlyProperty::.ctor()" or "System.Void TypeNamespace.ClassWithGetOnlyProperty::.ctor()" or "System.Void TypeNamespace.OtherClassWithStaticField::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.ctor()" or "System.Void TypeNamespace.ClassWithStaticProperty::.cctor()" or "System.Void TypeNamespace.ClassWithStaticMethod::.ctor()" or "System.Void TypeNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void TypeNamespace.ClassWithStringReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithIntReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void TypeNamespace.GenericClass`1::.ctor()" or "System.Void TypeNamespace.GenericClass`2::.ctor()" or "System.Void TypeNamespace.ClassWithGenericReturnType::.ctor()" or "System.Void TypeNamespace.OuterClassA/InnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassA/OtherInnerClassA::.ctor()" or "System.Void TypeNamespace.OuterClassB/InnerClassB::.ctor()" diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt index 016269181..0d4b152f8 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt @@ -203,16 +203,22 @@ Message: ----- Predicates ----- Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" -Result: True -Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" Message: -All Evaluations passed +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" + + Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" -Result: True -Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Result: False +Description: TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" Message: -All Evaluations passed +"Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass"" failed: + TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" + + Query: Method members that are "TypeNamespace.RegularClass TypeNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "TypeNamespace.OtherRegularClass" or "TypeNamespace.RegularClass" Result: False @@ -245,3 +251,117 @@ Message: +===== Open generic System.Type matches closed generic for negation ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1" +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1"" failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" + + + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1" +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1"" failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" + + + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1" +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1"" failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1" + + + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1" +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1"" failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1" + + + +===== Specific closed generic System.Type for negation ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015f... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015f..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" + + + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015f... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015f..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" + + + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=ne... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0... +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=ne..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0... + + + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=ne... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0... +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=ne..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0... + + + +===== Wrong closed generic System.Type is not a violation for negation ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Cultu... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that do not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Cultu... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt index 1c255b1fd..bbb07a82e 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt @@ -14,7 +14,7 @@ Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCall Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: @@ -46,7 +46,7 @@ Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCall Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: @@ -86,11 +86,11 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass" Result: False Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass"" failed: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass"" failed: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" @@ -133,12 +133,12 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass" Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass"" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass" @@ -164,25 +164,25 @@ Message: ----- Conditions ----- -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: @@ -190,25 +190,25 @@ All Evaluations passed ----- Predicates ----- -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.Othe... Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.Othe... Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.Othe... Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCal... +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.Othe... Result: True Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed Message: @@ -218,23 +218,41 @@ All Evaluations passed ----- Conditions ----- +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible) +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to + + + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible) +Result: False +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to +Message: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to + + + ----- Predicates ----- -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false) +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible) Result: False -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (impossible) Message: -"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false)" failed: - System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (impossible) -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false) +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible) Result: False -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (impossible) Message: -"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (always false)" failed: - System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (always false) +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (impossible) @@ -243,24 +261,12 @@ Message: ----- Conditions ----- Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" -Result: False -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" -Message: -"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes"" failed: - System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" - - +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ----- Predicates ----- Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" -Result: False -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" -Message: -"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes"" failed: - System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" - - +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ===== Multiple inputs ===== diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt index 3f12ef4d5..7805af951 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt @@ -235,3 +235,123 @@ Description: TypeNamespace.OtherRegularClass TypeNamespace.ClassWithOtherRegular Message: All Evaluations passed +===== Open generic System.Type matches closed generic IType ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1" +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1" +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1" +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1" +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +===== Specific closed generic System.Type matches exact return type ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015ff5fd... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015ff5fd... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, ... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, ... +Result: True +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +===== Specific closed generic System.Type rejects wrong generic argument ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" + + + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" + + + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neut... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015... +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neut..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015... + + + +Query: Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neut... +Result: False +Description: TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015... +Message: +"Method members that are "TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should be Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neut..." failed: + TypeNamespace.GenericClass`1 TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015... + + + +===== Two-arg open generic System.Type matches two-arg closed generic ===== + +----- Conditions ----- + +Query: Method members that are "TypeNamespace.GenericClass`2 TypeNamespace.ClassWithGenericReturnType::MethodRetur... should have return type "TypeNamespace.GenericClass`2" +Result: True +Description: TypeNamespace.GenericClass`2 TypeNamespace.ClassWithGenericReturnType::MethodReturningTwoArgGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "TypeNamespace.GenericClass`2 TypeNamespace.ClassWithGenericReturnType::MethodRetur... should be Method members that have return type "TypeNamespace.GenericClass`2" +Result: True +Description: TypeNamespace.GenericClass`2 TypeNamespace.ClassWithGenericReturnType::MethodReturningTwoArgGenericClass() passed +Message: +All Evaluations passed + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt index e53178654..019dc5223 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt @@ -14,7 +14,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Method Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -46,7 +46,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Method Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -86,11 +86,11 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: False Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by Types that are "MethodDependencyNamespace.MethodDependencyClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by any Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is called by Types that are "MethodDependencyNamespace.MethodDependencyClass" @@ -133,12 +133,12 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: False -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: - System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by Types that are "MethodDependencyNamespace.MethodDependencyClass" +"Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by any Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by any Types that are "MethodDependencyNamespace.MethodDependencyClass" @@ -164,25 +164,25 @@ Message: ----- Conditions ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -190,25 +190,25 @@ All Evaluations passed ----- Predicates ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -218,6 +218,18 @@ All Evaluations passed ----- Conditions ----- +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + ----- Predicates ----- Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always true) @@ -226,7 +238,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Called Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always false) +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always true) Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed Message: @@ -237,18 +249,12 @@ All Evaluations passed ----- Conditions ----- Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should not be called by "AttributeNamespace.ClassWithoutAttributes" -Result: True -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed -Message: -All Evaluations passed +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ----- Predicates ----- Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "AttributeNamespace.ClassWithoutAttributes" -Result: True -Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() passed -Message: -All Evaluations passed +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ===== Multiple inputs ===== diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt index 4662d45ec..5e54f3abc 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt @@ -14,7 +14,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Method Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -46,7 +46,7 @@ Description: System.Void MethodDependencyNamespace.MethodDependencyClass::Method Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any Types that are "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -86,11 +86,11 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: False Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" @@ -133,12 +133,12 @@ Message: -Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass" Result: False -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass" Message: -"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: - System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to Types that are "MethodDependencyNamespace.MethodDependencyClass" +"Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass"" failed: + System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to any Types that are "MethodDependencyNamespace.MethodDependencyClass" @@ -164,25 +164,25 @@ Message: ----- Conditions ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.OtherCallingClass" Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -190,25 +190,25 @@ All Evaluations passed ----- Predicates ----- -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespa... Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespa... Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespa... Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: All Evaluations passed -Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespace.O... +Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodDependencyNamespace.MethodDependencyClass" or "MethodDependencyNamespa... Result: True Description: System.Void MethodDependencyNamespace.MethodDependencyClass::MethodWithoutDependencies() passed Message: @@ -218,6 +218,18 @@ All Evaluations passed ----- Conditions ----- +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to one of no types (always true) +Result: True +Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + ----- Predicates ----- Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to one of no types (always true) @@ -237,18 +249,12 @@ All Evaluations passed ----- Conditions ----- Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" -Result: True -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed -Message: -All Evaluations passed +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ----- Predicates ----- Query: Method members that are "System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" -Result: True -Description: System.Void MethodDependencyNamespace.OtherCallingClass::MethodCallingCalledMethod() passed -Message: -All Evaluations passed +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. ===== Multiple inputs ===== diff --git a/TestAssemblies/TypeAssembly/Type.cs b/TestAssemblies/TypeAssembly/Type.cs index 6a0955d07..128716184 100644 --- a/TestAssemblies/TypeAssembly/Type.cs +++ b/TestAssemblies/TypeAssembly/Type.cs @@ -200,3 +200,26 @@ public OtherRegularClass MethodReturningOtherRegularClass() return new OtherRegularClass(); } } + +// Generic return type test classes +public class GenericClass { } + +public class GenericClass { } + +public class ClassWithGenericReturnType +{ + public GenericClass MethodReturningGenericClass() + { + return new GenericClass(); + } + + public GenericClass MethodReturningGenericClassWithOtherArg() + { + return new GenericClass(); + } + + public GenericClass MethodReturningTwoArgGenericClass() + { + return new GenericClass(); + } +}