BenMorris / NetArchTest

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

Add FromFiles method to allow loading a custom set of files #143

Closed thojaw closed 2 months ago

thojaw commented 3 months ago

In a scenario where the user doesn't want to load Assemblies into App Domain first, and can't provide a List of Assembly reflection types, the only alternative is Types.FromPath. But it lacks filtering capabilities and will load all files from the directory. (As a good example, the Unit Test Method FromPath_TypesReturned will also load Mono.Cecil assemblies etc. which can lead to many unwanted effects.)

Instead of providing filter capabilities to Types.FromPath method, as these filters could be complex and not necessarily just a search pattern, I decided to include the Method FromFiles where the user can use a totally custom filtered set of filenames as a input list.

Added UnitTest.

Updated other Tests where Files can be loaded from an absolute or relative directory to test both behaviours.