NetArchTest

A fluent API for .Net that can enforce architectural rules in unit tests.

MIT License

Stars
1.4K

Bot releases are visible (Hide)

NetArchTest - v1.3.2 Latest Release

Published by BenMorris over 3 years ago

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.

NetArchTest - v1.3.1

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.

NetArchTest - v1.3.0

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.

NetArchTest - v1.2.6

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:

  • ResideInNamespaceContaining now selects nested types (#59)
  • Fixed issues with detecting dependencies in generics (#57 and #58)
  • Fixed an issue where subclass detection was not taking the assembly into account properly (#52 and #56)
  • Fixed an issue where types were being excluded if they were in a namespace with a System prefix (#36, #47 and #48)

Thanks to @NeVeSpl and @jsantha for the pull requests.

NetArchTest - v1.2.5

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:

  • ResideInNamespaceStartingWith
  • ResideInNamespaceEndingWith
  • ResideInNamespaceContaining
  • DoNotResideInNamespaceStartingWith
  • DoNotResideInNamespaceEndingWith
  • DoNotResideInNamespaceContaining

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

NetArchTest - v1.2.4

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.

NetArchTest - v1.2.3

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)

NetArchTest - v1.2.2

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.

NetArchTest - v1.2.1

Published by BenMorris over 5 years ago

Accumulated bug fixes and minor changes:

  • You can now specify optional search directories when loading Types using the Types.InAssembly or Types.InAssemblies methods
  • Fixed a bug where rules were returning the wrong type list if a ShouldNot() condition was being used.
  • Types that cannot be loaded by Mono.Cecil no longer throw a BadImageFormatException
  • Fixed a typo in the "HasViolations" method - NB: this is a breaking change as it will require changes to existing implementations.
NetArchTest - v1.1.4

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.

NetArchTest - v1.1.3

Published by BenMorris over 5 years ago

Added the following new methods as predicates and conditions:

  • AreImmutable: no fields or properties can be updated
  • AreMutable: at least one field or property can be updated
  • OnlyHaveNullableMembers: All fields are nullable
  • HaveSomeNonNullableMembers: At least one field is non-nullable
NetArchTest - v1.1.2

Published by BenMorris over 5 years ago

  • Added methods that allow you to select types whose namespaces match a regular expression pattern. These have been added both as predicates and conditions.
NetArchTest - v1.1.1

Published by BenMorris almost 6 years ago

  • A call to 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.
  • Duplicate types are not longer returned in a call to GetResults() on a ConditionList
Package Rankings
Top 8.17% on Proxy.golang.org
Badges
Extracted from project README
Build status