(#555) added TypeRegistrarBaseTests

as a very simple test harness to test implementations of
ITypeRegistrar / ITypeResolver
This commit is contained in:
Nils Andresen
2021-11-13 21:33:58 +01:00
committed by Patrik Svensson
parent 2f6b4f53c4
commit 48df9cf68b
5 changed files with 211 additions and 5 deletions

View File

@ -74,6 +74,9 @@ return app.Run(args);
`TypeRegistrar` is a custom class that must be created by the user. This [example using `Microsoft.Extensions.DependencyInjection` as the container](https://github.com/spectreconsole/spectre.console/tree/main/examples/Cli/Injection) provides an example `TypeRegistrar` and `TypeResolver` that can be added to your application with small adjustments for your DI container.
Hint: If you do write your own implementation of `TypeRegistrar` and `TypeResolver` and you have some form of unit tests in place for your project,
there is a utility `TypeRegistrarBaseTests` available that can be used to ensure your implementations adhere to the required implementation. Simply call `TypeRegistrarBaseTests.RunAllTests()` and expect no `TypeRegistrarBaseTests.TestFailedException` to be thrown.
## Interception
`CommandApp` also provides a `SetInterceptor` configuration. An interceptor is run before all commands are executed. This is typically used for configuring logging or other infrastructure concerns.