diff --git a/ArchUnit.sln b/ArchUnit.sln index 65c417234..a9a94a8db 100644 --- a/ArchUnit.sln +++ b/ArchUnit.sln @@ -31,9 +31,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AttributeAssembly", "TestAs EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisibilityAssembly", "TestAssemblies\VisibilityAssembly\VisibilityAssembly.csproj", "{FBCD91F2-4DB9-44AC-8214-6F2FFF9178D5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoaderTestAssembly", "TestAssemblies\LoaderTestAssembly\LoaderTestAssembly.csproj", "{0243F2D4-AC89-4561-A936-D647B6BB821F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuplicateFullNameAssembly", "TestAssemblies\DuplicateFullNameAssembly\DuplicateFullNameAssembly.csproj", "{0243F2D4-AC89-4561-A936-D647B6BB821F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtherLoaderTestAssembly", "TestAssemblies\OtherLoaderTestAssembly\OtherLoaderTestAssembly.csproj", "{5A24529B-1794-4080-ADCC-77440BA0A0B3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtherDuplicateFullNameAssembly", "TestAssemblies\OtherDuplicateFullNameAssembly\OtherDuplicateFullNameAssembly.csproj", "{5A24529B-1794-4080-ADCC-77440BA0A0B3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilteredDirectoryLoaderTestAssembly", "TestAssemblies\FilteredDirectoryLoaderTestAssembly\FilteredDirectoryLoaderTestAssembly.csproj", "{E6CB8C69-25F5-4C94-8EA3-D56E444EB46B}" EndProject @@ -57,6 +57,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchUnitNET.MSTestV4", "Arc EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypeAssembly", "TestAssemblies\TypeAssembly\TypeAssembly.csproj", "{ABCA0EC3-E47E-453E-B4CC-3446ED4F7643}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MethodMemberAssembly", "TestAssemblies\MethodMemberAssembly\MethodMemberAssembly.csproj", "{05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -379,6 +381,18 @@ Global {ABCA0EC3-E47E-453E-B4CC-3446ED4F7643}.Release|x64.Build.0 = Release|Any CPU {ABCA0EC3-E47E-453E-B4CC-3446ED4F7643}.Release|x86.ActiveCfg = Release|Any CPU {ABCA0EC3-E47E-453E-B4CC-3446ED4F7643}.Release|x86.Build.0 = Release|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Debug|Any CPU.Build.0 = Debug|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Debug|x64.ActiveCfg = Debug|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Debug|x64.Build.0 = Debug|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Debug|x86.ActiveCfg = Debug|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Debug|x86.Build.0 = Debug|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Release|Any CPU.ActiveCfg = Release|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Release|Any CPU.Build.0 = Release|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Release|x64.ActiveCfg = Release|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Release|x64.Build.0 = Release|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Release|x86.ActiveCfg = Release|Any CPU + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -393,5 +407,6 @@ Global {E6CB8C69-25F5-4C94-8EA3-D56E444EB46B} = {B1191F18-91CB-4387-B775-A5EB64D3AC30} {AA695589-8CCC-4474-9A7F-01A6376C375A} = {B1191F18-91CB-4387-B775-A5EB64D3AC30} {ABCA0EC3-E47E-453E-B4CC-3446ED4F7643} = {B1191F18-91CB-4387-B775-A5EB64D3AC30} + {05F40E4D-94EC-4DF7-B0FA-1BCBFDF56088} = {B1191F18-91CB-4387-B775-A5EB64D3AC30} EndGlobalSection EndGlobal diff --git a/ArchUnitNET/Domain/Extensions/TypeExtensions.cs b/ArchUnitNET/Domain/Extensions/TypeExtensions.cs index a3779b0a6..c542a2dd1 100644 --- a/ArchUnitNET/Domain/Extensions/TypeExtensions.cs +++ b/ArchUnitNET/Domain/Extensions/TypeExtensions.cs @@ -334,6 +334,53 @@ public static IEnumerable GetInheritsBaseClassDepen : type.Dependencies.OfType(); } + public static bool HasAmbiguousFullName(this IType type, Architecture architecture) + { + return architecture.Types.Count(t => t.FullName == type.FullName) > 1; + } + + public static string GetFullNameForErrorMessage(this IType type, Architecture architecture) + { + return type.HasAmbiguousFullName(architecture) + ? type.FullName + ", " + type.Assembly.FullName + : type.FullName; + } + + public static string GetFullNameForErrorMessage( + this ITypeInstance typeInstance, + Architecture architecture + ) + { + var fullName = typeInstance.Type.GetFullNameForErrorMessage(architecture); + var genericArguments = typeInstance.GenericArguments.ToList(); + return genericArguments.Count == 0 + ? fullName + : fullName + + "<" + + string.Join( + ",", + genericArguments.Select(argument => + argument.GetFullNameForErrorMessage(architecture) + ) + ) + + ">"; + } + + public static string GetFullNameForDescription(this Type type) + { + var fullName = type.Namespace + "." + type.Name; + if (!type.IsConstructedGenericType) + { + return fullName; + } + + var argumentsDescription = string.Join( + ",", + type.GetGenericArguments().Select(GetFullNameForDescription) + ); + return fullName + "<" + argumentsDescription + ">"; + } + public static bool MatchesType(this ITypeInstance typeInstance, Type targetType) { var targetTypeFullNameWithoutAssembly = targetType.Namespace + "." + targetType.Name; 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..c42adde78 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,507 +37,164 @@ 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 ) { + var sizedObjectProvider = objectProvider as ISizedObjectProvider; IEnumerable Condition( IEnumerable methodMembers, 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()) + var isRequiredType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - 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) - { - 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, + (sizedObjectProvider != null && sizedObjectProvider.Count == 0) + ? "is not called by one of no types (impossible)" + : "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( IObjectProvider objectProvider ) { + var sizedObjectProvider = objectProvider as ISizedObjectProvider; IEnumerable Condition( IEnumerable methodMembers, 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, + (sizedObjectProvider != null && sizedObjectProvider.Count == 0) + ? "does not have dependencies in method body to one of no types (impossible)" + : "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, + BuildReturnTypeFailDescription(methodMember, architecture) ); - } - - 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, + BuildReturnTypeFailDescription(methodMember, architecture) + ); + } } } - 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.GetFullNameForDescription()}\"") ); + var description = + typeList.Count == 0 + ? "have return type of no types (impossible)" + : $"have return type {typeDescription}"; + return new OrderedArchitectureCondition(Condition, description); } //Negations @@ -560,512 +217,178 @@ 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 ) { + var sizedObjectProvider = objectProvider as ISizedObjectProvider; IEnumerable Condition( IEnumerable methodMembers, 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 + var isForbiddenType = CreateLookupFn( + objectProvider.GetObjects(architecture).ToList() + ); + foreach (var methodMember in methodMembers) { - 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) - { - 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, + (sizedObjectProvider != null && sizedObjectProvider.Count == 0) + ? "is called by one of no types (always true)" + : "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( IObjectProvider objectProvider ) { + var sizedObjectProvider = objectProvider as ISizedObjectProvider; IEnumerable Condition( IEnumerable methodMembers, 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, + (sizedObjectProvider != null && sizedObjectProvider.Count == 0) + ? "does have dependencies in method body to one of no types (always true)" + : "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, + BuildReturnTypeFailDescription(methodMember, architecture) ); - } - - 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)) - { - 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.All(type => !methodMember.ReturnTypeInstance.MatchesType(type))) + { + yield return new ConditionResult(methodMember, true); + } + else + { + yield return new ConditionResult( + methodMember, + false, + BuildReturnTypeFailDescription(methodMember, architecture) + ); + } } } - var description = "not have return type " + types.Description; - return new ArchitectureCondition( - Condition, - description - ).AsOrderedCondition(); + var typeDescription = string.Join( + " or ", + typeList.Select(type => $"\"{type.GetFullNameForDescription()}\"") + ); + var description = + typeList.Count == 0 + ? "not have return type of no types (always true)" + : $"not have return type {typeDescription}"; + return new OrderedArchitectureCondition(Condition, description); } - public static IOrderedCondition NotHaveReturnType( - Type firstType, - params Type[] moreTypes + private static string BuildReturnTypeFailDescription( + MethodMember methodMember, + Architecture architecture ) { - 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 returnTypeName = methodMember.ReturnTypeInstance.GetFullNameForErrorMessage( + architecture ); + var ambiguityNote = methodMember.ReturnType.HasAmbiguousFullName(architecture) + ? " (the return type's full name is ambiguous in this architecture; its assembly is shown to disambiguate it)" + : ""; + return "has return type \"" + returnTypeName + "\"" + ambiguityNote; } } } diff --git a/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Members/MethodMembers/MethodMemberPredicatesDefinition.cs index 1e576f656..a2d6b3092 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,101 @@ 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 @@ -341,312 +138,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 - ) - { - 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/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs index 93c536596..c8a5a16fc 100644 --- a/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs +++ b/ArchUnitNET/Fluent/Syntax/Elements/Types/TypeConditionsDefinition.cs @@ -61,6 +61,7 @@ public static IOrderedCondition BeAssignableTo( IObjectProvider objectProvider ) { + var sizedObjectProvider = objectProvider as ISizedObjectProvider; IEnumerable Condition( IEnumerable ruleTypes, Architecture architecture @@ -69,7 +70,10 @@ Architecture architecture var isExpectedType = CreateLookupFn( objectProvider.GetObjects(architecture).ToList() ); - var failDescription = "is not assignable to " + objectProvider.Description; + var failDescription = + (sizedObjectProvider != null && sizedObjectProvider.Count == 0) + ? "is not assignable to no types (always false)" + : "is not assignable to " + objectProvider.Description; foreach (var ruleType in ruleTypes) { if (ruleType.GetAssignableTypes().Any(isExpectedType)) @@ -503,6 +507,7 @@ public static IOrderedCondition NotBeAssignableTo( IObjectProvider objectProvider ) { + var sizedObjectProvider = objectProvider as ISizedObjectProvider; IEnumerable Condition( IEnumerable ruleTypes, Architecture architecture @@ -511,7 +516,10 @@ Architecture architecture var isForbiddenType = CreateLookupFn( objectProvider.GetObjects(architecture).ToList() ); - var failDescription = "is assignable to " + objectProvider.Description; + var failDescription = + (sizedObjectProvider != null && sizedObjectProvider.Count == 0) + ? "is assignable to no types (always true)" + : "is assignable to " + objectProvider.Description; foreach (var ruleType in ruleTypes) { if (ruleType.GetAssignableTypes().Any(isForbiddenType)) diff --git a/ArchUnitNETTests/ArchUnitNETTests.csproj b/ArchUnitNETTests/ArchUnitNETTests.csproj index 631aec75e..0ced15201 100644 --- a/ArchUnitNETTests/ArchUnitNETTests.csproj +++ b/ArchUnitNETTests/ArchUnitNETTests.csproj @@ -23,15 +23,16 @@ ReferenceOutputAssembly="false" /> + 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/MethodMemberAssemblyTestHelper.cs b/ArchUnitNETTests/AssemblyTestHelper/MethodMemberAssemblyTestHelper.cs new file mode 100644 index 000000000..b4dbb9e73 --- /dev/null +++ b/ArchUnitNETTests/AssemblyTestHelper/MethodMemberAssemblyTestHelper.cs @@ -0,0 +1,130 @@ +using System; +using System.Linq; +using ArchUnitNET.Domain; +using ArchUnitNET.Domain.Extensions; +using MethodMemberNamespace; + +namespace ArchUnitNETTests.AssemblyTestHelper; + +public class MethodMemberAssemblyTestHelper : AssemblyTestHelper +{ + public sealed override Architecture Architecture => + StaticTestArchitectures.MethodMemberArchitecture; + + public Class RegularClass; + public Type RegularClassSystemType = typeof(RegularClass); + + public Class OtherRegularClass; + public Type OtherRegularClassSystemType = typeof(OtherRegularClass); + + public Class ClassWithVirtualMethod; + public Class OtherClassWithVirtualMethod; + public Class ClassWithNonVirtualMethod; + public Class ClassWithStringReturnType; + public Class ClassWithRegularClassReturnType; + public Class ClassWithOtherRegularClassReturnType; + public Class ClassWithGenericReturnType; + + public MethodMember VirtualMethod; + public MethodMember OtherVirtualMethod; + public MethodMember NonVirtualMethod; + public MethodMember ClassWithVirtualMethodConstructor; + public MethodMember ClassWithNonVirtualMethodConstructor; + public MethodMember MethodReturningString; + public MethodMember MethodReturningRegularClass; + public MethodMember MethodReturningOtherRegularClass; + public MethodMember MethodReturningGenericClass; + public MethodMember MethodReturningTwoArgGenericClass; + + public Class ClassWithAmbiguousReturnType; + public MethodMember MethodWithAmbiguousReturnType; + public IType AmbiguousReturnType; + + public Class MethodDependencyClass; + public Type MethodDependencyClassSystemType = typeof(MethodDependencyClass); + + public Class OtherCallingClass; + public Type OtherCallingClassSystemType = typeof(OtherCallingClass); + + public MethodMember CalledMethod; + public MethodMember OtherCalledMethod; + public MethodMember MethodWithoutDependencies; + public MethodMember MethodCallingCalledMethod; + public MethodMember AnotherMethodCallingCalledMethod; + + public MethodMemberAssemblyTestHelper() + { + RegularClass = Architecture.GetClassOfType(typeof(RegularClass)); + OtherRegularClass = Architecture.GetClassOfType(typeof(OtherRegularClass)); + + ClassWithVirtualMethod = Architecture.GetClassOfType(typeof(ClassWithVirtualMethod)); + OtherClassWithVirtualMethod = Architecture.GetClassOfType( + typeof(OtherClassWithVirtualMethod) + ); + ClassWithNonVirtualMethod = Architecture.GetClassOfType(typeof(ClassWithNonVirtualMethod)); + ClassWithStringReturnType = Architecture.GetClassOfType(typeof(ClassWithStringReturnType)); + ClassWithRegularClassReturnType = Architecture.GetClassOfType( + typeof(ClassWithRegularClassReturnType) + ); + ClassWithOtherRegularClassReturnType = Architecture.GetClassOfType( + typeof(ClassWithOtherRegularClassReturnType) + ); + ClassWithGenericReturnType = Architecture.GetClassOfType( + typeof(ClassWithGenericReturnType) + ); + + VirtualMethod = ClassWithVirtualMethod.GetMethodMembersWithName("VirtualMethod()").First(); + OtherVirtualMethod = OtherClassWithVirtualMethod + .GetMethodMembersWithName("OtherVirtualMethod()") + .First(); + NonVirtualMethod = ClassWithNonVirtualMethod + .GetMethodMembersWithName("NonVirtualMethod()") + .First(); + ClassWithVirtualMethodConstructor = ClassWithVirtualMethod + .GetMethodMembersWithName(".ctor()") + .First(); + ClassWithNonVirtualMethodConstructor = ClassWithNonVirtualMethod + .GetMethodMembersWithName(".ctor()") + .First(); + MethodReturningString = ClassWithStringReturnType + .GetMethodMembersWithName("MethodReturningString()") + .First(); + MethodReturningRegularClass = ClassWithRegularClassReturnType + .GetMethodMembersWithName("MethodReturningRegularClass()") + .First(); + MethodReturningOtherRegularClass = ClassWithOtherRegularClassReturnType + .GetMethodMembersWithName("MethodReturningOtherRegularClass()") + .First(); + MethodReturningGenericClass = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningGenericClass()") + .First(); + MethodReturningTwoArgGenericClass = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningTwoArgGenericClass()") + .First(); + + ClassWithAmbiguousReturnType = Architecture.GetClassOfType( + typeof(DuplicateFullNameAssembly.ClassWithAmbiguousReturnType) + ); + MethodWithAmbiguousReturnType = ClassWithAmbiguousReturnType + .GetMethodMembersWithName("MethodWithAmbiguousReturnType()") + .First(); + AmbiguousReturnType = MethodWithAmbiguousReturnType.ReturnType; + + MethodDependencyClass = Architecture.GetClassOfType(typeof(MethodDependencyClass)); + OtherCallingClass = Architecture.GetClassOfType(typeof(OtherCallingClass)); + + CalledMethod = MethodDependencyClass.GetMethodMembersWithName("CalledMethod()").First(); + OtherCalledMethod = MethodDependencyClass + .GetMethodMembersWithName("OtherCalledMethod()") + .First(); + MethodWithoutDependencies = MethodDependencyClass + .GetMethodMembersWithName("MethodWithoutDependencies()") + .First(); + MethodCallingCalledMethod = OtherCallingClass + .GetMethodMembersWithName("MethodCallingCalledMethod()") + .First(); + AnotherMethodCallingCalledMethod = OtherCallingClass + .GetMethodMembersWithName("AnotherMethodCallingCalledMethod()") + .First(); + } +} diff --git a/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs b/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs index 5576ed067..cfb0795c0 100644 --- a/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs +++ b/ArchUnitNETTests/AssemblyTestHelper/TypeAssemblyTestHelper.cs @@ -142,6 +142,39 @@ 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); + + // 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; @@ -154,6 +187,20 @@ 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 MethodMember MethodReturningGenericClass; + public MethodMember MethodReturningGenericClassWithOtherArg; + public MethodMember MethodReturningTwoArgGenericClass; + public TypeAssemblyTestHelper() { SimpleEnum = Architecture.GetITypeOfType(typeof(SimpleEnum)); @@ -241,5 +288,63 @@ 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) + ); + + // 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 + .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(); + MethodReturningGenericClass = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningGenericClass()") + .First(); + MethodReturningGenericClassWithOtherArg = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningGenericClassWithOtherArg()") + .First(); + MethodReturningTwoArgGenericClass = ClassWithGenericReturnType + .GetMethodMembersWithName("MethodReturningTwoArgGenericClass()") + .First(); } } diff --git a/ArchUnitNETTests/Domain/Extensions/TypeExtensionTests.cs b/ArchUnitNETTests/Domain/Extensions/TypeExtensionTests.cs index e7386e52c..8747990a9 100644 --- a/ArchUnitNETTests/Domain/Extensions/TypeExtensionTests.cs +++ b/ArchUnitNETTests/Domain/Extensions/TypeExtensionTests.cs @@ -1,3 +1,6 @@ +extern alias DuplicateFullNameAssemblyAlias; +extern alias OtherDuplicateFullNameAssemblyAlias; + using System; using System.Linq; using ArchUnitNET.Domain; @@ -8,6 +11,9 @@ using ArchUnitNETTests.Loader; using Xunit; +using DuplicateClass = DuplicateFullNameAssemblyAlias::DuplicateClassAcrossAssemblies.DuplicateClass; +using OtherDuplicateClass = OtherDuplicateFullNameAssemblyAlias::DuplicateClassAcrossAssemblies.DuplicateClass; + namespace ArchUnitNETTests.Domain.Extensions { public class TypeExtensionTests @@ -83,6 +89,45 @@ public void FullNameEqualsTest() Assert.False(_exampleAttribute.FullNameEquals(null)); } + [Fact] + public void GetFullNameForErrorMessageTest() + { + Assert.Equal( + _methodOriginClass.FullName, + _methodOriginClass.GetFullNameForErrorMessage(Architecture) + ); + + var loaderArchitecture = StaticTestArchitectures.LoaderTestArchitecture; + var duplicateClass = loaderArchitecture.GetClassOfType(typeof(DuplicateClass)); + var otherDuplicateClass = loaderArchitecture.GetClassOfType( + typeof(OtherDuplicateClass) + ); + + Assert.Equal( + duplicateClass.FullName + ", " + duplicateClass.Assembly.FullName, + duplicateClass.GetFullNameForErrorMessage(loaderArchitecture) + ); + Assert.Equal( + otherDuplicateClass.FullName + ", " + otherDuplicateClass.Assembly.FullName, + otherDuplicateClass.GetFullNameForErrorMessage(loaderArchitecture) + ); + } + + [Fact] + public void HasAmbiguousFullNameTest() + { + Assert.False(_methodOriginClass.HasAmbiguousFullName(Architecture)); + + var loaderArchitecture = StaticTestArchitectures.LoaderTestArchitecture; + var duplicateClass = loaderArchitecture.GetClassOfType(typeof(DuplicateClass)); + var otherDuplicateClass = loaderArchitecture.GetClassOfType( + typeof(OtherDuplicateClass) + ); + + Assert.True(duplicateClass.HasAmbiguousFullName(loaderArchitecture)); + Assert.True(otherDuplicateClass.HasAmbiguousFullName(loaderArchitecture)); + } + [Fact] public void HasMembersWithFullNameTest() { 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 ba31a1b45..e1726b2c1 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/MethodMemberSyntaxElementsTests.cs @@ -1,472 +1,686 @@ -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 ArchUnitNET.Domain.Exceptions; +using ArchUnitNETTests.AssemblyTestHelper; +using MethodMemberNamespace; 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; + [Fact] + public async Task BeConstructorTest() + { + var helper = new MethodMemberAssemblyTestHelper(); + + 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); - public MethodMemberSyntaxElementsTests() + 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 async Task BeNoConstructorTest() { - _methodMembers = Architecture.MethodMembers; - _types = Architecture.Types; + var helper = new MethodMemberAssemblyTestHelper(); + + 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 AreConstructorsTest() + public async Task BeVirtualTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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 AreVirtualTest() + public async Task NotBeVirtualTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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 CalledByTest() + public async Task BeCalledByTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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"); + should.BeCalledBy(new List()).AssertOnlyViolations(helper); + should.BeCalledBy(new List()).AssertOnlyViolations(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) }).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + should.Be(MethodMembers().That().AreCalledBy(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertException(helper); + + helper.AddSnapshotHeader("Multiple inputs"); + MethodMembers().That().Are(helper.CalledMethod, helper.OtherCalledMethod).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 HaveDependencyInMethodBodyTest() + public async Task NotBeCalledByTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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"); + should.NotBeCalledBy(new List()).AssertNoViolations(helper); + should.NotBeCalledBy(new List()).AssertNoViolations(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) }).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + 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); + MethodMembers().That().Are(helper.CalledMethod, helper.MethodWithoutDependencies).Should().NotBeCalledBy(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void HaveReturnTypeConditionTest() + public async Task HaveDependencyInMethodBodyToTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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"); + should.HaveDependencyInMethodBodyTo(new List()).AssertOnlyViolations(helper); + should.HaveDependencyInMethodBodyTo(new List()).AssertOnlyViolations(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) }).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + 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); + MethodMembers().That().Are(helper.MethodCallingCalledMethod, helper.MethodWithoutDependencies).Should().HaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void NotHaveReturnTypeConditionTest() + public async Task NotHaveDependencyInMethodBodyToTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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"); + should.NotHaveDependencyInMethodBodyTo(new List()).AssertNoViolations(helper); + should.NotHaveDependencyInMethodBodyTo(new List()).AssertNoViolations(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) }).AssertException(helper); + + helper.AddSnapshotSubHeader("Predicates"); + 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); + MethodMembers().That().Are(helper.MethodCallingCalledMethod, helper.MethodWithoutDependencies).Should().NotHaveDependencyInMethodBodyTo(helper.MethodDependencyClass).AssertAnyViolations(helper); + + await helper.AssertSnapshotMatches(); } [Fact] - public void HaveReturnTypePredicateTest() + public async Task HaveReturnTypeTest() { - 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 MethodMemberAssemblyTestHelper(); + + 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); + + 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(); } - } - internal class ReturnTypeClass - { - public void ReturnTypeMethodVoid() { } + [Fact] + public async Task DoNotHaveReturnTypeTest() + { + var helper = new MethodMemberAssemblyTestHelper(); + + 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(); + + 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); + + helper.AddSnapshotSubHeader("Predicates"); + 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(); + } - public string ReturnTypeMethodString() + [Fact] + public async Task HaveReturnTypeWithAmbiguousReturnTypeTest() { - return ""; + var helper = new MethodMemberAssemblyTestHelper(); + + helper.AddSnapshotHeader( + "Failure message disambiguates return type with the same full name in multiple assemblies" + ); + var should = MethodMembers().That().Are(helper.MethodWithAmbiguousReturnType).Should(); + + should.HaveReturnType(helper.RegularClass).AssertOnlyViolations(helper); + should.NotHaveReturnType(helper.AmbiguousReturnType).AssertOnlyViolations(helper); + + await helper.AssertSnapshotMatches(); } - public ReturnTypeClass ReturnTypeMethodClass() + [Fact] + public async Task BeMethodMembersThatTest() { - return new ReturnTypeClass(); + var helper = new MethodMemberAssemblyTestHelper(); + + 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..f2f06c33c --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.BeCalledByTest.verified.txt @@ -0,0 +1,291 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by Types that are "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by any Types that are "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by Types that are "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by any Types that are "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by any Types that are "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that are called by "MethodMemberNamespace.MethodDependencyClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not called by one of no types (impossible) +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible)" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not called by one of no types (impossible) + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not called by one of no types (impossible) +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible)" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not called by one of no types (impossible) + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible)" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by one of no types (impossible)" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are called by one of no types (impossible) + + + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be 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 MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are called by "AttributeNamespace.ClassWithoutAttributes" +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass::OtherCal... should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::OtherCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWi... should be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWi... should be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not called by "MethodMemberNamespace.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..04fca7dbd --- /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 MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be a constructor +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be Method members that are constructors +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are constructors +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are constructors +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are constructors" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are constructors + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::.ctor()" should be a constructor +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() passed +Result: True +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is no constructor +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be a constructor" failed: + System.Void MethodMemberNamespace.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..9c28ed334 --- /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 MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be method members that are constructors +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() passed +Message: +All Evaluations passed + +===== Violations ===== + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be method members that are constructors +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void MethodMemberNamespace.RegularClass::.ctor()" or "System.Void MethodMemberNamespace.OtherRegularClass::.ctor()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithStringReturnType::.ctor()" or "System.Void MethodMemberNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void MethodMemberNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void MethodMemberNamespace.GenericClass`1::.ctor()" or "System.Void MethodMemberNamespace.GenericClass`2::.ctor()" or "System.Void MethodMemberNamespace.ClassWithGenericReturnType::.ctor()" or "System.Void MethodMemberNamespace.MethodDependencyClass::.ctor()" or "System.Void MethodMemberNamespace.OtherCallingClass::.ctor()" or "System.Void DuplicateClassAcrossAssemblies.DuplicateClass::.ctor()" or "System.Void DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::.ctor()" or "System.Void DuplicateFullNameAssembly.DuplicateFullNameAssembly::.ctor()" or "System.Void DuplicateFullNameAssembly.ClassWithDuplicateParameters::.ctor()" or "System.Void DuplicateFullNameAssembly.CustomType::.ctor()" or "System.Void OtherDuplicateFullNameAssembly.OtherDuplicateFullNameAssembly::.ctor()" or "System.Void DuplicateClassAcrossAssemblies.DuplicateClass::.ctor()" +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be method members that are constructors" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is not "System.Void MethodMemberNamespace.RegularClass::.ctor()" or "System.Void MethodMemberNamespace.OtherRegularClass::.ctor()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.OtherClassWithVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::.ctor()" or "System.Void MethodMemberNamespace.ClassWithStringReturnType::.ctor()" or "System.Void MethodMemberNamespace.ClassWithRegularClassReturnType::.ctor()" or "System.Void MethodMemberNamespace.ClassWithOtherRegularClassReturnType::.ctor()" or "System.Void MethodMemberNamespace.GenericClass`1::.ctor()" or "System.Void MethodMemberNamespace.GenericClass`2::.ctor()" or "System.Void MethodMemberNamespace.ClassWithGenericReturnType::.ctor()" or "System.Void MethodMemberNamespace.MethodDependencyClass::.ctor()" or "System.Void MethodMemberNamespace.OtherCallingClass::.ctor()" or "System.Void DuplicateClassAcrossAssemblies.DuplicateClass::.ctor()" or "System.Void DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::.ctor()" or "System.Void DuplicateFullNameAssembly.DuplicateFullNameAssembly::.ctor()" or "System.Void DuplicateFullNameAssembly.ClassWithDuplicateParameters::.ctor()" or "System.Void DuplicateFullNameAssembly.CustomType::.ctor()" or "System.Void OtherDuplicateFullNameAssembly.OtherDuplicateFullNameAssembly::.ctor()" or "System.Void DuplicateClassAcrossAssemblies.DuplicateClass::.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..d5dda8470 --- /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 MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be no constructor +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are no constructors +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() is a constructor +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() is a constructor + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be Method members that are no constructors +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() is not Method members that are no constructors +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be Method members that are no constructors" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() is not Method members that are no constructors + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::No... should be no constructor +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: True +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor() is a constructor +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod::.ctor()" should be no constructor" failed: + System.Void MethodMemberNamespace.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..664cc8019 --- /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 MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be virtual +Result: False +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be virtual" failed: + System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be Method members that are virtual +Result: False +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not Method members that are virtual +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be Method members that are virtual" failed: + System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not Method members that are virtual + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void MethodMemberNamespace.OtherClassWithVirtualMethod::... should be virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: True +Description: System.Void MethodMemberNamespace.OtherClassWithVirtualMethod::OtherVirtualMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::No... should be virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() passed +Result: False +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() is not virtual +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::No... should be virtual" failed: + System.Void MethodMemberNamespace.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..4212c9f88 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt @@ -0,0 +1,367 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type Types that are "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type Types that are "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type Types that are "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type Types that are "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type Types that are "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type Types that are "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type Types that are "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type Types that are "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.RegularClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that do not have return type "MethodMemberNamespace.OtherRegularClass" or "MethodMemberNamespace.RegularClass" + + + +===== Multiple inputs ===== + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "MethodMemberNames... should not have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.OtherRegularClass MethodMemberNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() passed +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "MethodMemberNames... should not have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +===== Open generic System.Type matches closed generic for negation ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" + + + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" + + + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1" + + + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1" + + + +===== Specific closed generic System.Type for negation ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" + + + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" + + + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Ver... +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=n... +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Ver..." failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=n... + + + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Ver... +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=n... +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Ver..." failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=n... + + + +===== Wrong closed generic System.Type is not a violation for negation ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should not have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly... +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that do not have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly... +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.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 new file mode 100644 index 000000000..b5d28f807 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveDependencyInMethodBodyToTest.verified.txt @@ -0,0 +1,291 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to Types that are "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to Types that are "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() is not Method members that have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCalling... +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCalling... +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCalling... +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCalling... +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to one of no types (impossible) +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to one of no types (impossible) + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to one of no types (impossible) +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does not have dependencies in method body to one of no types (impossible) + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodMemberNamespace.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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible) +Result: False +Description: System.Void MethodMemberNamespace.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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that have dependencies in method body to one of no types (impossible)" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that have dependencies in method body to one of no types (impossible) + + + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should 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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be 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 ===== + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodMemberNamespace.OtherCallingClass::Ano... should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::AnotherMethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass:... should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass:... should have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() does not have dependencies in method body to "MethodMemberNamespace.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..6023e6b09 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeTest.verified.txt @@ -0,0 +1,357 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type Types that are "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type Types that are "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type Types that are "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type Types that are "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() has return type "MethodMemberNamespace.RegularClass" + + + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type Types that are "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type Types that are "MethodMemberNamespace.OtherRegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type Types that are "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type Types that are "MethodMemberNamespace.OtherRegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Result: False +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.OtherRegularClass"" failed: + MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() is not Method members that have return type "MethodMemberNamespace.OtherRegularClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" should be Method members that have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Message: +All Evaluations passed + +===== Multiple inputs ===== + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "MethodMemberNames... should have return type "MethodMemberNamespace.RegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Result: False +Description: MethodMemberNamespace.OtherRegularClass MethodMemberNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() has return type "MethodMemberNamespace.OtherRegularClass" +Message: +"Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "MethodMemberNames... should have return type "MethodMemberNamespace.RegularClass"" failed: + MethodMemberNamespace.OtherRegularClass MethodMemberNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() has return type "MethodMemberNamespace.OtherRegularClass" + + + +Query: Method members that are "MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass()" or "MethodMemberNames... should have return type "MethodMemberNamespace.RegularClass" or "MethodMemberNamespace.OtherRegularClass" +Result: True +Description: MethodMemberNamespace.RegularClass MethodMemberNamespace.ClassWithRegularClassReturnType::MethodReturningRegularClass() passed +Result: True +Description: MethodMemberNamespace.OtherRegularClass MethodMemberNamespace.ClassWithOtherRegularClassReturnType::MethodReturningOtherRegularClass() passed +Message: +All Evaluations passed + +===== Open generic System.Type matches closed generic IType ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +===== Specific closed generic System.Type matches exact return type ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1" +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Version=1.... +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.RegularClass, MethodMemberAssembly, Version=1.... +Result: True +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() passed +Message: +All Evaluations passed + +===== Specific closed generic System.Type rejects wrong generic argument ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" + + + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1" +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should have return type "MethodMemberNamespace.GenericClass`1"" failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "MethodMemberNamespace.GenericClass`1" + + + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Versi... +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=neu... +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Versi..." failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=neu... + + + +Query: Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Versi... +Result: False +Description: MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=neu... +Message: +"Method members that are "MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGene... should be Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Versi..." failed: + MethodMemberNamespace.GenericClass`1 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() is not Method members that have return type "MethodMemberNamespace.GenericClass`1[[MethodMemberNamespace.OtherRegularClass, MethodMemberAssembly, Version=1.0.0.0, Culture=neu... + + + +===== Two-arg open generic System.Type matches two-arg closed generic ===== + +----- Conditions ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`2 MethodMemberNamespace.ClassWi... should have return type "MethodMemberNamespace.GenericClass`2" +Result: True +Description: MethodMemberNamespace.GenericClass`2 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningTwoArgGenericClass() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "MethodMemberNamespace.GenericClass`2 MethodMemberNamespace.ClassWi... should be Method members that have return type "MethodMemberNamespace.GenericClass`2" +Result: True +Description: MethodMemberNamespace.GenericClass`2 MethodMemberNamespace.ClassWithGenericReturnType::MethodReturningTwoArgGenericClass() passed +Message: +All Evaluations passed + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeWithAmbiguousReturnTypeTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeWithAmbiguousReturnTypeTest.verified.txt new file mode 100644 index 000000000..50246eeb2 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.HaveReturnTypeWithAmbiguousReturnTypeTest.verified.txt @@ -0,0 +1,20 @@ +===== Failure message disambiguates return type with the same full name in multiple assemblies ===== + +Query: Method members that are "DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType()" should have return type "MethodMemberNamespace.RegularClass" +Result: False +Description: DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType() has return type "DuplicateClassAcrossAssemblies.DuplicateClass, DuplicateFullNameAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015ff5fd0dc0bfa4" (the return type's full name is ambiguous in this architecture; its assembly is shown to disambiguate it) +Message: +"Method members that are "DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType()" should have return type "MethodMemberNamespace.RegularClass"" failed: + DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType() has return type "DuplicateClassAcrossAssemblies.DuplicateClass, DuplicateFullNameAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015ff5fd0dc0bfa4" (the return type's full name is ambiguous in this architecture; its assembly is shown to disambiguate it) + + + +Query: Method members that are "DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType()" should not have return type "DuplicateClassAcrossAssemblies.DuplicateClass" +Result: False +Description: DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType() has return type "DuplicateClassAcrossAssemblies.DuplicateClass, DuplicateFullNameAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015ff5fd0dc0bfa4" (the return type's full name is ambiguous in this architecture; its assembly is shown to disambiguate it) +Message: +"Method members that are "DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType()" should not have return type "DuplicateClassAcrossAssemblies.DuplicateClass"" failed: + DuplicateClassAcrossAssemblies.DuplicateClass DuplicateFullNameAssembly.ClassWithAmbiguousReturnType::MethodWithAmbiguousReturnType() has return type "DuplicateClassAcrossAssemblies.DuplicateClass, DuplicateFullNameAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015ff5fd0dc0bfa4" (the return type's full name is ambiguous in this architecture; its assembly is shown to disambiguate it) + + + 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..80a3af717 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotBeCalledByTest.verified.txt @@ -0,0 +1,279 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by Types that are "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by any Types that are "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by Types that are "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by any Types that are "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by any Types that are "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by any Types that are "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is not Method members that are not called by "MethodMemberNamespace.MethodDependencyClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not be called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that are not called by any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by one of no types (always true) +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be called by one of no types (always true) +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always true) +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by one of no types (always true) +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Message: +All Evaluations passed + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should not be 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 MethodMemberNamespace.MethodDependencyClass::CalledMethod()" should be Method members that are not called by "AttributeNamespace.ClassWithoutAttributes" +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" or "System.Void MethodMemberNamespace.OtherCallingClass:... should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWi... should not be called by "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +"Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWi... should not be called by "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() is called by "MethodMemberNamespace.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..fcd102afd --- /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 MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should not be virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" should be Method members that are not virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should not be virtual +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should not be virtual" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are not virtual +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are not virtual +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod()" should be Method members that are not virtual" failed: + System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is not Method members that are not virtual + + + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" or "System.String MethodMemberNamespace.ClassWithStringReturn... should not be virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Result: True +Description: System.String MethodMemberNamespace.ClassWithStringReturnType::MethodReturningString() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod:... should not be virtual +Result: False +Description: System.Void MethodMemberNamespace.ClassWithVirtualMethod::VirtualMethod() is virtual +Result: True +Description: System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod() passed +Message: +"Method members that are "System.Void MethodMemberNamespace.ClassWithNonVirtualMethod::NonVirtualMethod()" or "System.Void MethodMemberNamespace.ClassWithVirtualMethod:... should not be virtual" failed: + System.Void MethodMemberNamespace.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..5474eadb5 --- /dev/null +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/MethodMemberSyntaxElementsTests.NotHaveDependencyInMethodBodyToTest.verified.txt @@ -0,0 +1,279 @@ +===== No Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any Types that are "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Violations ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to Types that are "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to Types that are "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to any Types that are "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() is not Method members that do not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + +===== Multiple arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.Other... +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.Other... +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.Other... +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" should be Method members that do not have dependencies in method body to any "MethodMemberNamespace.MethodDependencyClass" or "MethodMemberNamespace.Other... +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +===== Empty arguments ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to one of no types (always true) +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should not have dependencies in method body to one of no types (always true) +Result: True +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +----- Predicates ----- + +Query: Method members that are "System.Void MethodMemberNamespace.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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() passed +Message: +All Evaluations passed + +===== Type not in architecture ===== + +----- Conditions ----- + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should 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 MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" should be Method members that do not have dependencies in method body to "AttributeNamespace.ClassWithoutAttributes" +Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. + +===== Multiple inputs ===== + +Query: Method members that are "System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies()" or "System.Void MethodMemberNamespace.MethodDependencyCl... should not have dependencies in method body to "MethodMemberNamespace.OtherCallingClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::CalledMethod() passed +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Message: +All Evaluations passed + +Query: Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass:... should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Result: True +Description: System.Void MethodMemberNamespace.MethodDependencyClass::MethodWithoutDependencies() passed +Result: False +Description: System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" +Message: +"Method members that are "System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod()" or "System.Void MethodMemberNamespace.MethodDependencyClass:... should not have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass"" failed: + System.Void MethodMemberNamespace.OtherCallingClass::MethodCallingCalledMethod() does have dependencies in method body to "MethodMemberNamespace.MethodDependencyClass" + + + diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.BeAssignableToTest.verified.txt b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.BeAssignableToTest.verified.txt index 3b40cb3ba..a7b6acdd6 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.BeAssignableToTest.verified.txt +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/Snapshots/TypeSyntaxElementsTests.BeAssignableToTest.verified.txt @@ -319,7 +319,29 @@ Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in prov Query: Types that are "TypeNamespace.BaseClassForAssign" should be Types that are assignable to "AttributeNamespace.ClassWithoutAttributes" Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class. -===== Empty Arguments (Predicates only) ===== +===== Empty Arguments ===== + +----- Conditions ----- + +Query: Types that are "TypeNamespace.BaseClassForAssign" should be assignable to no types (always false) +Result: False +Description: TypeNamespace.BaseClassForAssign is not assignable to no types (always false) +Message: +"Types that are "TypeNamespace.BaseClassForAssign" should be assignable to no types (always false)" failed: + TypeNamespace.BaseClassForAssign is not assignable to no types (always false) + + + +Query: Types that are "TypeNamespace.BaseClassForAssign" should be assignable to no types (always false) +Result: False +Description: TypeNamespace.BaseClassForAssign is not assignable to no types (always false) +Message: +"Types that are "TypeNamespace.BaseClassForAssign" should be assignable to no types (always false)" failed: + TypeNamespace.BaseClassForAssign is not assignable to no types (always false) + + + +----- Predicates ----- Query: Types that are "TypeNamespace.BaseClassForAssign" should be Types that are assignable to no types (always false) Result: False diff --git a/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs b/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs index a7563eec6..76b7d6512 100644 --- a/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs +++ b/ArchUnitNETTests/Fluent/Syntax/Elements/TypeSyntaxElementsTests.cs @@ -226,8 +226,14 @@ public async Task BeAssignableToTest() helper.AddSnapshotSubHeader("Predicates"); should.Be(Types().That().AreAssignableTo(new List { typeof(AttributeNamespace.ClassWithoutAttributes) })).AssertException(helper); - helper.AddSnapshotHeader("Empty Arguments (Predicates only)"); + helper.AddSnapshotHeader("Empty Arguments"); should = Types().That().Are(helper.BaseClassForAssign).Should(); + + helper.AddSnapshotSubHeader("Conditions"); + should.BeAssignableTo(new List()).AssertOnlyViolations(helper); + should.BeAssignableTo(new List()).AssertOnlyViolations(helper); + + helper.AddSnapshotSubHeader("Predicates"); should.Be(Types().That().AreAssignableTo(new List())).AssertOnlyViolations(helper); should.Be(Types().That().AreAssignableTo(new List())).AssertOnlyViolations(helper); diff --git a/ArchUnitNETTests/Loader/ArchLoaderTests.cs b/ArchUnitNETTests/Loader/ArchLoaderTests.cs index e7e586e6f..280b2b46b 100644 --- a/ArchUnitNETTests/Loader/ArchLoaderTests.cs +++ b/ArchUnitNETTests/Loader/ArchLoaderTests.cs @@ -1,5 +1,5 @@ -extern alias LoaderTestAssemblyAlias; -extern alias OtherLoaderTestAssemblyAlias; +extern alias DuplicateFullNameAssemblyAlias; +extern alias OtherDuplicateFullNameAssemblyAlias; using System; using System.Collections.Generic; @@ -15,8 +15,8 @@ using static ArchUnitNET.Fluent.ArchRuleDefinition; using static ArchUnitNETTests.StaticTestArchitectures; -using DuplicateClass = LoaderTestAssemblyAlias::DuplicateClassAcrossAssemblies.DuplicateClass; -using OtherDuplicateClass = OtherLoaderTestAssemblyAlias::DuplicateClassAcrossAssemblies.DuplicateClass; +using DuplicateClass = DuplicateFullNameAssemblyAlias::DuplicateClassAcrossAssemblies.DuplicateClass; +using OtherDuplicateClass = OtherDuplicateFullNameAssemblyAlias::DuplicateClassAcrossAssemblies.DuplicateClass; namespace ArchUnitNETTests.Loader { @@ -203,8 +203,14 @@ public void SameFullNameInMultipleAssemblies() .Types.Where(type => type.Namespace.FullName == "DuplicateClassAcrossAssemblies") .ToList(); Assert.Equal(2, types.Count); - Assert.Single(types, type => type.Assembly.Name.StartsWith("LoaderTestAssembly")); - Assert.Single(types, type => type.Assembly.Name.StartsWith("OtherLoaderTestAssembly")); + Assert.Single( + types, + type => type.Assembly.Name.StartsWith("DuplicateFullNameAssembly") + ); + Assert.Single( + types, + type => type.Assembly.Name.StartsWith("OtherDuplicateFullNameAssembly") + ); // Loaded as stub types @@ -221,8 +227,14 @@ public void SameFullNameInMultipleAssemblies() ) .ToList(); Assert.Equal(2, types.Count); - Assert.Single(types, type => type.Assembly.Name.StartsWith("LoaderTestAssembly")); - Assert.Single(types, type => type.Assembly.Name.StartsWith("OtherLoaderTestAssembly")); + Assert.Single( + types, + type => type.Assembly.Name.StartsWith("DuplicateFullNameAssembly") + ); + Assert.Single( + types, + type => type.Assembly.Name.StartsWith("OtherDuplicateFullNameAssembly") + ); } [Fact] diff --git a/ArchUnitNETTests/StaticTestArchitectures.cs b/ArchUnitNETTests/StaticTestArchitectures.cs index f05c652ef..af8d59c4d 100644 --- a/ArchUnitNETTests/StaticTestArchitectures.cs +++ b/ArchUnitNETTests/StaticTestArchitectures.cs @@ -42,8 +42,8 @@ public static class StaticTestArchitectures .WithoutRuleEvaluationCache() .WithoutArchitectureCache() .LoadAssemblies( - typeof(LoaderTestAssembly.LoaderTestAssembly).Assembly, - typeof(OtherLoaderTestAssembly.OtherLoaderTestAssembly).Assembly + typeof(DuplicateFullNameAssembly.DuplicateFullNameAssembly).Assembly, + typeof(OtherDuplicateFullNameAssembly.OtherDuplicateFullNameAssembly).Assembly ) .Build(); @@ -59,6 +59,16 @@ public static class StaticTestArchitectures .LoadAssemblies(typeof(TypeNamespace.RegularClass).Assembly) .Build(); + public static readonly Architecture MethodMemberArchitecture = new ArchLoader() + .WithoutRuleEvaluationCache() + .WithoutArchitectureCache() + .LoadAssemblies( + typeof(MethodMemberNamespace.RegularClass).Assembly, + typeof(DuplicateFullNameAssembly.DuplicateFullNameAssembly).Assembly, + typeof(OtherDuplicateFullNameAssembly.OtherDuplicateFullNameAssembly).Assembly + ) + .Build(); + public static readonly Architecture ArchUnitNETTestAssemblyArchitecture = new ArchLoader() .LoadAssemblies(typeof(Class1).Assembly) .Build(); diff --git a/TestAssemblies/DuplicateFullNameAssembly/ClassWithAmbiguousReturnType.cs b/TestAssemblies/DuplicateFullNameAssembly/ClassWithAmbiguousReturnType.cs new file mode 100644 index 000000000..3977917ea --- /dev/null +++ b/TestAssemblies/DuplicateFullNameAssembly/ClassWithAmbiguousReturnType.cs @@ -0,0 +1,9 @@ +namespace DuplicateFullNameAssembly; + +public class ClassWithAmbiguousReturnType +{ + public DuplicateClassAcrossAssemblies.DuplicateClass MethodWithAmbiguousReturnType() + { + return new DuplicateClassAcrossAssemblies.DuplicateClass(); + } +} diff --git a/TestAssemblies/LoaderTestAssembly/DuplicateClassAcrossAssemblies.cs b/TestAssemblies/DuplicateFullNameAssembly/DuplicateClassAcrossAssemblies.cs similarity index 100% rename from TestAssemblies/LoaderTestAssembly/DuplicateClassAcrossAssemblies.cs rename to TestAssemblies/DuplicateFullNameAssembly/DuplicateClassAcrossAssemblies.cs diff --git a/TestAssemblies/LoaderTestAssembly/LoaderTestAssembly.cs b/TestAssemblies/DuplicateFullNameAssembly/DuplicateFullNameAssembly.cs similarity index 83% rename from TestAssemblies/LoaderTestAssembly/LoaderTestAssembly.cs rename to TestAssemblies/DuplicateFullNameAssembly/DuplicateFullNameAssembly.cs index d78500f17..77aec1eaf 100644 --- a/TestAssemblies/LoaderTestAssembly/LoaderTestAssembly.cs +++ b/TestAssemblies/DuplicateFullNameAssembly/DuplicateFullNameAssembly.cs @@ -1,6 +1,6 @@ -namespace LoaderTestAssembly; +namespace DuplicateFullNameAssembly; -public class LoaderTestAssembly { } +public class DuplicateFullNameAssembly { } public class ClassWithDuplicateParameters { diff --git a/TestAssemblies/LoaderTestAssembly/LoaderTestAssembly.csproj b/TestAssemblies/DuplicateFullNameAssembly/DuplicateFullNameAssembly.csproj similarity index 100% rename from TestAssemblies/LoaderTestAssembly/LoaderTestAssembly.csproj rename to TestAssemblies/DuplicateFullNameAssembly/DuplicateFullNameAssembly.csproj 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/MethodMemberAssembly/MethodMemberAssembly.csproj b/TestAssemblies/MethodMemberAssembly/MethodMemberAssembly.csproj new file mode 100644 index 000000000..6865534e9 --- /dev/null +++ b/TestAssemblies/MethodMemberAssembly/MethodMemberAssembly.csproj @@ -0,0 +1,12 @@ + + + net10.0 + enable + enable + true + false + True + ..\..\strongNameKey.snk + 1.0.0.0 + + diff --git a/TestAssemblies/MethodMemberAssembly/MethodMemberAssemblyClasses.cs b/TestAssemblies/MethodMemberAssembly/MethodMemberAssemblyClasses.cs new file mode 100644 index 000000000..c3500ab7e --- /dev/null +++ b/TestAssemblies/MethodMemberAssembly/MethodMemberAssemblyClasses.cs @@ -0,0 +1,95 @@ +namespace MethodMemberNamespace; + +public class RegularClass { } + +public class OtherRegularClass { } + +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 ClassWithRegularClassReturnType +{ + public RegularClass MethodReturningRegularClass() + { + return new RegularClass(); + } +} + +public class ClassWithOtherRegularClassReturnType +{ + public OtherRegularClass MethodReturningOtherRegularClass() + { + return new OtherRegularClass(); + } +} + +public class GenericClass { } + +public class GenericClass { } + +public class ClassWithGenericReturnType +{ + public GenericClass MethodReturningGenericClass() + { + return new GenericClass(); + } + + public GenericClass MethodReturningTwoArgGenericClass() + { + return new GenericClass(); + } +} + +public class MethodDependencyClass +{ + public void MethodWithSingleDependency() + { + CalledMethod(); + } + + public void CalledMethod() { } + + public void OtherMethodWithSingleDependency() + { + OtherCalledMethod(); + } + + public void OtherCalledMethod() { } + + public void MethodWithoutDependencies() { } +} + +public class OtherCallingClass +{ + public void MethodCallingCalledMethod() + { + var dep = new MethodDependencyClass(); + dep.CalledMethod(); + } + + public void AnotherMethodCallingCalledMethod() + { + var dep = new MethodDependencyClass(); + dep.OtherCalledMethod(); + } +} diff --git a/TestAssemblies/OtherLoaderTestAssembly/DuplicateClassAcrossAssemblies.cs b/TestAssemblies/OtherDuplicateFullNameAssembly/DuplicateClassAcrossAssemblies.cs similarity index 100% rename from TestAssemblies/OtherLoaderTestAssembly/DuplicateClassAcrossAssemblies.cs rename to TestAssemblies/OtherDuplicateFullNameAssembly/DuplicateClassAcrossAssemblies.cs diff --git a/TestAssemblies/OtherDuplicateFullNameAssembly/OtherDuplicateFullNameAssembly.cs b/TestAssemblies/OtherDuplicateFullNameAssembly/OtherDuplicateFullNameAssembly.cs new file mode 100644 index 000000000..26baf6473 --- /dev/null +++ b/TestAssemblies/OtherDuplicateFullNameAssembly/OtherDuplicateFullNameAssembly.cs @@ -0,0 +1,3 @@ +namespace OtherDuplicateFullNameAssembly; + +public class OtherDuplicateFullNameAssembly { } diff --git a/TestAssemblies/OtherLoaderTestAssembly/OtherLoaderTestAssembly.csproj b/TestAssemblies/OtherDuplicateFullNameAssembly/OtherDuplicateFullNameAssembly.csproj similarity index 100% rename from TestAssemblies/OtherLoaderTestAssembly/OtherLoaderTestAssembly.csproj rename to TestAssemblies/OtherDuplicateFullNameAssembly/OtherDuplicateFullNameAssembly.csproj diff --git a/TestAssemblies/OtherLoaderTestAssembly/OtherLoaderTestAssembly.cs b/TestAssemblies/OtherLoaderTestAssembly/OtherLoaderTestAssembly.cs deleted file mode 100644 index c775e8915..000000000 --- a/TestAssemblies/OtherLoaderTestAssembly/OtherLoaderTestAssembly.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace OtherLoaderTestAssembly; - -public class OtherLoaderTestAssembly { } diff --git a/TestAssemblies/TypeAssembly/Type.cs b/TestAssemblies/TypeAssembly/Type.cs index 3a6d36f96..128716184 100644 --- a/TestAssemblies/TypeAssembly/Type.cs +++ b/TestAssemblies/TypeAssembly/Type.cs @@ -152,3 +152,74 @@ 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(); + } +} + +// 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(); + } +}