BenMorris / NetArchTest

A fluent API for .Net that can enforce architectural rules in unit tests.
MIT License
1.39k stars 82 forks source link

Reference types defined by part of the namespace #51

Closed electronickai closed 4 years ago

electronickai commented 4 years ago

Hi, in ArchUnit you can refer to packages by using a part of the name ..persistence... In NetArchTest it seems that you have always to provide the complete name of the namespace.

How would you refer to classes in persistence namespaces that are distrubuted in different functional areas like MyApp.User.Persistence and MyApp.Booking.Persistence? (e.g. to prevent any persistence classes from accessing any business service class)

ajedwards commented 4 years ago

You should be able to use the ResideInNamespaceContaining method, Kai.

For your examples, try something like:

types.Should().ResideInNamespaceContaining("Persistence")

Or maybe even:

types.Should().ResideInNamespaceEndingWith("Persistence")

Check out the ResideInNamespaceMatching method too for more complex regular expression matching.