A fluent API for .Net that can enforce architectural rules in unit tests.
MIT License
Bot releases are visible (Hide)
String literals are only checked on the HaveDependencyOnAny and HaveDependencyOnAll methods. This will minimise the risk of any false positives arising from the string literal checking behaviour that was re-introduced in v1.3.1 (#94)
Fixed an issue where the dependency search was not consistently checking whether a type has a dependency on itself (#95)
Removed some unnecessary dependencies from the project (#93)
Thanks for @NeVeSpl and @tibel for the pull requests.
Published by BenMorris over 3 years ago
Checking for static classes added via new predicates (AreStatic and AreNotStatic) and conditions (BeStatic, NotBeStatic) (#89).
The dependency search now checks for dependenices in string literals (this is restored functionality lost in versionn 1.2.6 (#79, #82).
Compiler-generated types that are located outside of any namespace should not be detected by the dependency search (#78).
Updated the Mono.Cecil dependency to the latest version (#87).
Thanks for @RyanMarcotte, @Lorilatschki and @NeVeSpl, and @tibel for the pull requests.
Published by BenMorris almost 4 years ago
A significant rewrite of dependency searches which has improved performance and accuracy of searches. This fixed a number of problems including finding dependencies in attributes, generic dependencies, implemented interfaces, generic constraints, arrays, reference types and pointers (see #62 for full details).
Added method overloads for HaveNameStartingWith
, DoNotHaveNameStartingWith
, HaveNameEndingWith
, and DoNotHaveNameEndingWith
that accept a StringComparison
parameter.
Added new methods that allow you to specify lists of permissible dependencies: OnlyHaveDependenciesOn()
and HaveDependenciesOtherThan()
(#72)
Fixed an issue where the "IsPublic" test for internal classes was returning the wrong result (#74).
Thanks to @NeVeSpl and @RyanMarcotte for the pull requests.
Published by BenMorris about 4 years ago
Custom rules can now be created and applied as predicates and conditions. A custom rule has to implement ICustomRule
and can be executed using a MeetCustomRule()
method (see the README and the sample project for examples).
Added HaveCustomAttributeOrInherit and NotHaveCustomAttributeOrInherit as predicates and conditions to test for inherited custom attributes (#55)
The following bugs have been fixed:
Thanks to @NeVeSpl and @jsantha for the pull requests.
Published by BenMorris over 4 years ago
The dependency search logic has been re-written so it can scale for very large projects. It can now handle projects with thousands of modules and dependencies in a few seconds as opposed to a few hours.
A pattern matching bug has been fixed where false positives were being returned for both namespace and class names matching the input text.
Dependencies will now be found in a method's parameter list and a list of generic arguments.
Fixed an issue where the wrong types were being returned when the Or() method was used in conditions (#38).
A number of namespace matching methods have been added as predicates and conditions:
Fixed the TypeDefinition.GetType() extension method so it will load managed C++ template instances.
Dependencies have been updated and test\sample projects brought up to .Net Core 3.1.
Many thanks to the contributors to this release: @AlexeyGorelenkov, @NeVeSpl and @vip32
Published by BenMorris over 4 years ago
All compiler-generated classes are ignore now, not just those created to enable async\await.
The params keyword has been added to the parameters of dependency checking methods.
Published by BenMorris almost 5 years ago
Added a new property FailingTypeNames
to TestResults
. This allows you to list the failing types for a test without the risk of tripping a FileLoadException
due to missing dependencies (issue #26)
Published by BenMorris about 5 years ago
You can now distinguish between nested public and nested private classes. BeNestedPublic() and BeNestedPrivate() have been added as predicates and conditions. BeNested() will continue to select nested classes regardless of scope.
New dependency checking methods have been added that accept a list of dependencies. HaveDependencyOnAny() and HaveDependencyOnAll() are available as predictaes and conditions.
Dependency checking now splits instructions into individual tokens when searching.
Published by BenMorris over 5 years ago
Accumulated bug fixes and minor changes:
Published by BenMorris over 5 years ago
Added policies, a construct that lets you aggregate groups of rules together for reporting.
Many thanks to @ewassef for the idea and initial implementation.
Published by BenMorris over 5 years ago
Added the following new methods as predicates and conditions:
Published by BenMorris over 5 years ago
Published by BenMorris almost 6 years ago
GetResults()
on a ConditionList
now also returns a list of failing types. This constitutes a breaking change as the result is now a TestResult
instance rather than a boolean value.ConditionList