Added a TypeRegistrar to CommandAppTester

exposed as a public property.
For convenience, and to keep the similarity to the real CommandApp
it is also available in the ctor of CommandAppTester.
This commit is contained in:
Nils Andresen
2021-06-21 15:52:12 +02:00
committed by Patrik Svensson
parent b92827ce3d
commit 6b5b31957c
4 changed files with 91 additions and 3 deletions

View File

@ -11,6 +11,20 @@ namespace Spectre.Console.Testing
private Action<CommandApp>? _appConfiguration;
private Action<IConfigurator>? _configuration;
/// <summary>
/// Initializes a new instance of the <see cref="CommandAppTester"/> class.
/// </summary>
/// <param name="registrar">The registrar.</param>
public CommandAppTester(ITypeRegistrar? registrar = null)
{
Registrar = registrar;
}
/// <summary>
/// Gets or sets the Registrar to use in the CommandApp.
/// </summary>
public ITypeRegistrar? Registrar { get; set; }
/// <summary>
/// Sets the default command.
/// </summary>
@ -88,7 +102,7 @@ namespace Spectre.Console.Testing
CommandContext? context = null;
CommandSettings? settings = null;
var app = new CommandApp();
var app = new CommandApp(Registrar);
_appConfiguration?.Invoke(app);
if (_configuration != null)