Removed the additional registration of ICommand

This commit is contained in:
Nils Andresen 2021-09-09 15:27:52 +02:00 committed by Patrik Svensson
parent d34012cad0
commit 49e8a980a7
2 changed files with 8 additions and 7 deletions

View File

@ -27,7 +27,6 @@ namespace Spectre.Console.Cli
if (command.CommandType != null)
{
registrar?.Register(typeof(ICommand), command.CommandType);
registrar?.Register(command.CommandType, command.CommandType);
}

View File

@ -382,10 +382,12 @@ namespace Spectre.Console.Tests.Unit.Cli
});
// Then
registrar.Registrations.ContainsKey(typeof(ICommand)).ShouldBeTrue();
registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(GenericCommand<FooCommandSettings>));
registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(DogCommand));
registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(HorseCommand));
registrar.Registrations.ContainsKey(typeof(GenericCommand<FooCommandSettings>)).ShouldBeTrue();
registrar.Registrations.ContainsKey(typeof(DogCommand)).ShouldBeTrue();
registrar.Registrations.ContainsKey(typeof(HorseCommand)).ShouldBeTrue();
registrar.Registrations[typeof(GenericCommand<FooCommandSettings>)].ShouldContain(typeof(GenericCommand<FooCommandSettings>));
registrar.Registrations[typeof(DogCommand)].ShouldContain(typeof(DogCommand));
registrar.Registrations[typeof(HorseCommand)].ShouldContain(typeof(HorseCommand));
}
[Fact]
@ -406,8 +408,8 @@ namespace Spectre.Console.Tests.Unit.Cli
});
// Then
registrar.Registrations.ContainsKey(typeof(ICommand)).ShouldBeTrue();
registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(DogCommand));
registrar.Registrations.ContainsKey(typeof(DogCommand)).ShouldBeTrue();
registrar.Registrations[typeof(DogCommand)].ShouldContain(typeof(DogCommand));
}
[Fact]