Skip to content

Commit 8b45ac2

Browse files
committed
Simplify namespace matching in CleanArchitectureTests
Updated namespace matching rules to use simpler wildcard patterns instead of complex regular expressions. This affects repository, service, and controller class/interface checks, improving readability and maintainability of the architecture tests.
1 parent cffcda9 commit 8b45ac2

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

source/AAS.TwinEngine.DataEngine.UnitTests/CleanArchitectureTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void ApiShallNotHaveDependenciesToInfrastructure()
8080
public void RepositoryClassesShallBeInCorrectNamespace()
8181
{
8282
Classes().That().HaveNameEndingWith("Repository").Should()
83-
.ResideInNamespaceMatching($"{BaseNamespace}\\.Infrastructure\\.DataAccess.*")
83+
.ResideInNamespaceMatching($"{BaseNamespace}.Infrastructure.Providers*")
8484
.WithoutRequiringPositiveResults()
8585
.Check(_architecture);
8686
}
@@ -93,7 +93,7 @@ public void RepositoryInterfacesShallBeInCorrectNamespace()
9393
.And()
9494
.DoNotHaveFullName($"{BaseNamespace}.Infrastructure.DataAccess.GenericRepository.IMongoDbRepository")
9595
.Should()
96-
.ResideInNamespaceMatching($"{BaseNamespace}\\.ApplicationLogic($|\\.*)")
96+
.ResideInNamespaceMatching($"{BaseNamespace}.ApplicationLogic.*")
9797
.WithoutRequiringPositiveResults()
9898
.Check(_architecture);
9999
}
@@ -102,7 +102,7 @@ public void RepositoryInterfacesShallBeInCorrectNamespace()
102102
public void ServicesShallBeInCorrectNamespace()
103103
{
104104
Classes().That().HaveNameEndingWith("Service").Should()
105-
.ResideInNamespaceMatching($"{BaseNamespace}\\.ApplicationLogic\\.Services($|\\.*)")
105+
.ResideInNamespaceMatching($"{BaseNamespace}.ApplicationLogic.Service.*")
106106
.Check(_architecture);
107107
}
108108

@@ -111,15 +111,15 @@ public void ServiceInterfacesShallBeInCorrectNamespace()
111111
{
112112
Interfaces().That().HaveNameEndingWith("Service")
113113
.Should()
114-
.ResideInNamespaceMatching($"{BaseNamespace}\\.ApplicationLogic\\.Services($|\\.*)")
114+
.ResideInNamespaceMatching($"{BaseNamespace}.ApplicationLogic.Service.*")
115115
.Check(_architecture);
116116
}
117117

118118
[Fact]
119119
public void ControllerShallBeInCorrectNamespace()
120120
{
121121
Classes().That().HaveNameEndingWith("Controller").Should()
122-
.ResideInNamespaceMatching($"{BaseNamespace}\\.Api($|\\.*)")
122+
.ResideInNamespaceMatching($"{BaseNamespace}.Api.*")
123123
.Check(_architecture);
124124
}
125125
}

source/AAS.TwinEngine.Plugin.TestPlugin.UnitTests/CleanArchitectureTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void ApiShallNotHaveDependenciesToInfrastructure()
8080
public void RepositoryClassesShallBeInCorrectNamespace()
8181
{
8282
Classes().That().HaveNameEndingWith("Repository").Should()
83-
.ResideInNamespaceMatching($"{BaseNamespace}\\.Infrastructure\\.DataAccess.*")
83+
.ResideInNamespaceMatching($"{BaseNamespace}.Infrastructure.Providers*")
8484
.WithoutRequiringPositiveResults()
8585
.Check(_architecture);
8686
}
@@ -93,7 +93,7 @@ public void RepositoryInterfacesShallBeInCorrectNamespace()
9393
.And()
9494
.DoNotHaveFullName($"{BaseNamespace}.Infrastructure.DataAccess.GenericRepository.IMongoDbRepository")
9595
.Should()
96-
.ResideInNamespaceMatching($"{BaseNamespace}\\.ApplicationLogic($|\\.*)")
96+
.ResideInNamespaceMatching($"{BaseNamespace}.ApplicationLogic.*")
9797
.WithoutRequiringPositiveResults()
9898
.Check(_architecture);
9999
}
@@ -102,7 +102,7 @@ public void RepositoryInterfacesShallBeInCorrectNamespace()
102102
public void ServicesShallBeInCorrectNamespace()
103103
{
104104
Classes().That().HaveNameEndingWith("Service").Should()
105-
.ResideInNamespaceMatching($"{BaseNamespace}\\.ApplicationLogic\\.Services($|\\.*)")
105+
.ResideInNamespaceMatching($"{BaseNamespace}.ApplicationLogic.Service.*")
106106
.Check(_architecture);
107107
}
108108

@@ -111,15 +111,15 @@ public void ServiceInterfacesShallBeInCorrectNamespace()
111111
{
112112
Interfaces().That().HaveNameEndingWith("Service")
113113
.Should()
114-
.ResideInNamespaceMatching($"{BaseNamespace}\\.ApplicationLogic\\.Services($|\\.*)")
114+
.ResideInNamespaceMatching($"{BaseNamespace}.ApplicationLogic.Service.*")
115115
.Check(_architecture);
116116
}
117117

118118
[Fact]
119119
public void ControllerShallBeInCorrectNamespace()
120120
{
121121
Classes().That().HaveNameEndingWith("Controller").Should()
122-
.ResideInNamespaceMatching($"{BaseNamespace}\\.Api($|\\.*)")
122+
.ResideInNamespaceMatching($"{BaseNamespace}.Api.*")
123123
.Check(_architecture);
124124
}
125125
}

0 commit comments

Comments
 (0)