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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,7 @@ public static IPredicate<T> DoNotDependOnAny(IObjectProvider<IType> objectProvid
IEnumerable<T> Filter(IEnumerable<T> objects, Architecture architecture)
{
var types = objectProvider.GetObjects(architecture);
return objects.Where(obj =>
!obj.GetTypeDependencies(architecture).Intersect(types).Any()
);
return objects.Where(obj => !obj.GetTypeDependencies().Intersect(types).Any());
}

var description = objectProvider.FormatDescription(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ArchUnitNET.Domain;
using ArchUnitNET.Domain.Extensions;
Expand Down Expand Up @@ -57,6 +58,12 @@ public class DependencyAssemblyTestHelper : AssemblyTestHelper
public Class OtherClassWithoutDependencies;
public Type OtherClassWithoutDependenciesSystemType = typeof(OtherClassWithoutDependencies);

public Class ClassWithReferencedTypeDependency;
public Type ClassWithReferencedTypeDependencySystemType =
typeof(ClassWithReferencedTypeDependency);

public Type ReferencedType = typeof(List<>);

public MethodMember MethodWithSingleDependency;

public MethodMember CalledMethod;
Expand Down Expand Up @@ -96,6 +103,9 @@ public DependencyAssemblyTestHelper()
OtherClassWithoutDependencies = Architecture.GetClassOfType(
typeof(OtherClassWithoutDependencies)
);
ClassWithReferencedTypeDependency = Architecture.GetClassOfType(
typeof(ClassWithReferencedTypeDependency)
);
MethodWithSingleDependency = Architecture
.MethodMembers.WhereNameIs("MethodWithSingleDependency()")
.First();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,18 @@ public async Task DependOnAnyTest()
helper.AddSnapshotSubHeader("Predicates as conditions");
should.BeTypesThat().DependOnAny(typeof(AttributeNamespace.ClassWithoutAttributes)).AssertException<TypeDoesNotExistInArchitecture>(helper);

helper.AddSnapshotHeader("Referenced type");
should = Types().That().Are(helper.ClassWithReferencedTypeDependency).Should();

helper.AddSnapshotSubHeader("Conditions");
should.DependOnAny(helper.ReferencedType).AssertNoViolations(helper);

helper.AddSnapshotSubHeader("Predicates");
should.Be(Types().That().DependOnAny(helper.ReferencedType)).AssertNoViolations(helper);

helper.AddSnapshotSubHeader("Predicates as conditions");
should.BeTypesThat().DependOnAny(helper.ReferencedType).AssertNoViolations(helper);

helper.AddSnapshotHeader("Empty arguments");
should = Types().That().Are(helper.ClassWithMultipleDependencies).Should();

Expand Down Expand Up @@ -1692,6 +1704,18 @@ public async Task NotDependOnAnyTest()
helper.AddSnapshotSubHeader("Predicates as conditions");
should.BeTypesThat().DoNotDependOnAny(typeof(AttributeNamespace.ClassWithoutAttributes)).AssertException<TypeDoesNotExistInArchitecture>(helper);

helper.AddSnapshotHeader("Referenced type");
should = Types().That().Are(helper.ClassWithReferencedTypeDependency).Should();

helper.AddSnapshotSubHeader("Conditions");
should.NotDependOnAny(helper.ReferencedType).AssertOnlyViolations(helper);

helper.AddSnapshotHeader("Predicates");
should.Be(Types().That().DoNotDependOnAny(helper.ReferencedType)).AssertOnlyViolations(helper);

helper.AddSnapshotSubHeader("Predicates as conditions");
should.BeTypesThat().DoNotDependOnAny(helper.ReferencedType).AssertOnlyViolations(helper);

helper.AddSnapshotHeader("Empty arguments");
should = Types().That().Are(helper.ChildClass).Should();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,32 @@ Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in prov
Query: Types that are "TypeDependencyNamespace.ClassWithMultipleDependencies" should be types that depend on "AttributeNamespace.ClassWithoutAttributes"
Exception: Type AttributeNamespace.ClassWithoutAttributes does not exist in provided architecture or is no class.

===== Referenced type =====

----- Conditions -----

Query: Types that are "TypeDependencyNamespace.ClassWithReferencedTypeDependency" should depend on "System.Collections.Generic.List`1"
Result: True
Description: TypeDependencyNamespace.ClassWithReferencedTypeDependency passed
Message:
All Evaluations passed

----- Predicates -----

Query: Types that are "TypeDependencyNamespace.ClassWithReferencedTypeDependency" should be Types that depend on "System.Collections.Generic.List`1"
Result: True
Description: TypeDependencyNamespace.ClassWithReferencedTypeDependency passed
Message:
All Evaluations passed

----- Predicates as conditions -----

Query: Types that are "TypeDependencyNamespace.ClassWithReferencedTypeDependency" should be types that depend on "System.Collections.Generic.List`1"
Result: True
Description: TypeDependencyNamespace.ClassWithReferencedTypeDependency passed
Message:
All Evaluations passed

===== Empty arguments =====

----- Conditions -----
Expand Down

Large diffs are not rendered by default.

Loading