From 49e8a980a7de6c11e391c45eb3a7bfda0397193f Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Thu, 9 Sep 2021 15:27:52 +0200 Subject: [PATCH] Removed the additional registration of ICommand --- .../Internal/Extensions/TypeRegistrarExtensions.cs | 1 - .../Unit/Cli/CommandAppTests.cs | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Spectre.Console/Cli/Internal/Extensions/TypeRegistrarExtensions.cs b/src/Spectre.Console/Cli/Internal/Extensions/TypeRegistrarExtensions.cs index 14f713d5..4b73fb53 100644 --- a/src/Spectre.Console/Cli/Internal/Extensions/TypeRegistrarExtensions.cs +++ b/src/Spectre.Console/Cli/Internal/Extensions/TypeRegistrarExtensions.cs @@ -27,7 +27,6 @@ namespace Spectre.Console.Cli if (command.CommandType != null) { - registrar?.Register(typeof(ICommand), command.CommandType); registrar?.Register(command.CommandType, command.CommandType); } diff --git a/test/Spectre.Console.Tests/Unit/Cli/CommandAppTests.cs b/test/Spectre.Console.Tests/Unit/Cli/CommandAppTests.cs index a3c91689..2e7bf78b 100644 --- a/test/Spectre.Console.Tests/Unit/Cli/CommandAppTests.cs +++ b/test/Spectre.Console.Tests/Unit/Cli/CommandAppTests.cs @@ -382,10 +382,12 @@ namespace Spectre.Console.Tests.Unit.Cli }); // Then - registrar.Registrations.ContainsKey(typeof(ICommand)).ShouldBeTrue(); - registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(GenericCommand)); - registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(DogCommand)); - registrar.Registrations[typeof(ICommand)].ShouldContain(typeof(HorseCommand)); + registrar.Registrations.ContainsKey(typeof(GenericCommand)).ShouldBeTrue(); + registrar.Registrations.ContainsKey(typeof(DogCommand)).ShouldBeTrue(); + registrar.Registrations.ContainsKey(typeof(HorseCommand)).ShouldBeTrue(); + registrar.Registrations[typeof(GenericCommand)].ShouldContain(typeof(GenericCommand)); + 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]