Skip to content

Commit 6136263

Browse files
committed
remove HaveDependencyOn and DoNotHaveDependencyOn
1 parent 77e5222 commit 6136263

6 files changed

Lines changed: 12 additions & 55 deletions

File tree

samples/NetArchTest.SampleRules/ExamplePolicies.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public static void Run()
2222
t.That()
2323
.ResideInNamespace("NetArchTest.SampleLibrary.Presentation")
2424
.ShouldNot()
25-
.HaveDependencyOn("NetArchTest.SampleLibrary.Data"),
25+
.HaveDependencyOnAny("NetArchTest.SampleLibrary.Data"),
2626
"Enforcing layered architecture", "Controllers should not directly reference repositories"
2727
)
2828
.Add(t =>
29-
t.That().HaveDependencyOn("System.Data")
29+
t.That().HaveDependencyOnAny("System.Data")
3030
.And().ResideInNamespace(("ArchTest"))
3131
.Should().ResideInNamespace("NetArchTest.SampleLibrary.Data"),
3232
"Controlling external dependencies", "Only classes in the data namespace can have a dependency on System.Data"

samples/NetArchTest.SampleRules/ExampleRules.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static void Run()
2020
.That()
2121
.ResideInNamespace("NetArchTest.SampleLibrary.Presentation")
2222
.ShouldNot()
23-
.HaveDependencyOn("NetArchTest.SampleLibrary.Data")
23+
.HaveDependencyOnAny("NetArchTest.SampleLibrary.Data")
2424
.GetResult().IsSuccessful;
2525

2626
//****************************************************
@@ -29,7 +29,7 @@ public static void Run()
2929
// Only classes in the data namespace can have a dependency on System.Data
3030

3131
result = Types.InCurrentDomain()
32-
.That().HaveDependencyOn("System.Data")
32+
.That().HaveDependencyOnAny("System.Data")
3333
.And().ResideInNamespace(("ArchTest"))
3434
.Should().ResideInNamespace(("NetArchTest.SampleLibrary.Data"))
3535
.GetResult().IsSuccessful;

src/NetArchTest.Rules/Condition.cs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -599,18 +599,7 @@ public ConditionList NotResideInNamespaceContaining(string name)
599599
{
600600
_sequence.AddFunctionCall(FunctionDelegates.ResideInNamespaceMatching, $"^.*{name}.*$", false);
601601
return new ConditionList(_types, _should, _sequence);
602-
}
603-
604-
/// <summary>
605-
/// Selects types that have a dependency on a particular type.
606-
/// </summary>
607-
/// <param name="dependency">The dependency to match against. This can be a namespace or a specific type.</param>
608-
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
609-
public ConditionList HaveDependencyOn(string dependency)
610-
{
611-
_sequence.AddFunctionCall(FunctionDelegates.HaveDependencyOnAny, new List<string> { dependency }, true);
612-
return new ConditionList(_types, _should, _sequence);
613-
}
602+
}
614603

615604
/// <summary>
616605
/// Selects types that have a dependency on any of the supplied types.
@@ -644,17 +633,7 @@ public ConditionList OnlyHaveDependenciesOn(params string[] dependencies)
644633
_sequence.AddFunctionCall(FunctionDelegates.OnlyHaveDependenciesOnAnyOrNone, dependencies, true);
645634
return new ConditionList(_types, _should, _sequence);
646635
}
647-
648-
/// <summary>
649-
/// Selects types that do not have a dependency on a particular type.
650-
/// </summary>
651-
/// <param name="dependency">The dependency type to match against. This can be a namespace or a specific type.</param>
652-
/// <returns>An updated set of conditions that can be applied to a list of types.</returns>
653-
public ConditionList NotHaveDependencyOn(string dependency)
654-
{
655-
_sequence.AddFunctionCall(FunctionDelegates.HaveDependencyOnAny, new List<string> { dependency }, false);
656-
return new ConditionList(_types, _should, _sequence);
657-
}
636+
658637
/// <summary>
659638
/// Selects types that do not have a dependency on any of the particular types.
660639
/// </summary>

src/NetArchTest.Rules/Predicate.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -615,18 +615,7 @@ public PredicateList DoNotResideInNamespaceContaining(string name)
615615
{
616616
_sequence.AddFunctionCall(FunctionDelegates.ResideInNamespaceMatching, $"^.*{name}.*$", false);
617617
return new PredicateList(_types, _sequence);
618-
}
619-
620-
/// <summary>
621-
/// Selects types that have a dependency on a particular type.
622-
/// </summary>
623-
/// <param name="dependency">The dependency type to match against. This can be a namespace or a specific type.</param>
624-
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
625-
public PredicateList HaveDependencyOn(string dependency)
626-
{
627-
_sequence.AddFunctionCall(FunctionDelegates.HaveDependencyOnAny, new List<string> { dependency }, true);
628-
return new PredicateList(_types, _sequence);
629-
}
618+
}
630619

631620
/// <summary>
632621
/// Selects types that have a dependency on any of the supplied types.
@@ -659,18 +648,7 @@ public PredicateList OnlyHaveDependenciesOn(params string[] dependencies)
659648
{
660649
_sequence.AddFunctionCall(FunctionDelegates.OnlyHaveDependenciesOnAnyOrNone, dependencies, true);
661650
return new PredicateList(_types, _sequence);
662-
}
663-
664-
/// <summary>
665-
/// Selects types that do not have a dependency on a particular type.
666-
/// </summary>
667-
/// <param name="dependency">The dependency type to match against. This can be a namespace or a specific type.</param>
668-
/// <returns>An updated set of predicates that can be applied to a list of types.</returns>
669-
public PredicateList DoNotHaveDependencyOn(string dependency)
670-
{
671-
_sequence.AddFunctionCall(FunctionDelegates.HaveDependencyOnAny, new List<string> { dependency }, false);
672-
return new PredicateList(_types, _sequence);
673-
}
651+
}
674652

675653
/// <summary>
676654
/// Selects types that do not have a dependency on any of the particular types.

test/NetArchTest.Rules.UnitTests/ConditionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ public void HaveDependency_MatchesFound_ClassSelected()
826826
.And()
827827
.HaveNameStartingWith("HasDepend")
828828
.Should()
829-
.HaveDependencyOn(typeof(ExampleDependency).FullName)
829+
.HaveDependencyOnAny(typeof(ExampleDependency).FullName)
830830
.GetResult();
831831

832832
Assert.True(result.IsSuccessful);
@@ -890,7 +890,7 @@ public void NotHaveDependency_MatchesFound_ClassSelected()
890890
.And()
891891
.HaveNameStartingWith("NoDependency")
892892
.Should()
893-
.NotHaveDependencyOn(typeof(ExampleDependency).FullName)
893+
.NotHaveDependencyOnAny(typeof(ExampleDependency).FullName)
894894
.GetResult();
895895

896896
Assert.True(result.IsSuccessful);

test/NetArchTest.Rules.UnitTests/PredicateTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ public void HaveDepencency_MatchesFound_ClassSelected()
940940
.That()
941941
.ResideInNamespace(typeof(HasDependency).Namespace)
942942
.And()
943-
.HaveDependencyOn(typeof(ExampleDependency).FullName)
943+
.HaveDependencyOnAny(typeof(ExampleDependency).FullName)
944944
.GetTypes();
945945

946946
Assert.Equal(2, result.Count()); // Two types found
@@ -1004,7 +1004,7 @@ public void DoNotHaveDepencency_MatchesFound_ClassSelected()
10041004
.That()
10051005
.ResideInNamespace(typeof(HasDependency).Namespace)
10061006
.And()
1007-
.DoNotHaveDependencyOn(typeof(ExampleDependency).FullName)
1007+
.DoNotHaveDependencyOnAny(typeof(ExampleDependency).FullName)
10081008
.GetTypes();
10091009

10101010
Assert.Equal(2, result.Count()); // Two types found

0 commit comments

Comments
 (0)