fix dependency injection of comands in webfront preventing ui actions from working
This commit is contained in:
parent
b59504a882
commit
22f9e581ed
@ -38,6 +38,7 @@ namespace ApplicationTests
|
|||||||
.AddSingleton<IManagerCommand, FlagClientCommand>()
|
.AddSingleton<IManagerCommand, FlagClientCommand>()
|
||||||
.AddSingleton<IManagerCommand, UnflagClientCommand>()
|
.AddSingleton<IManagerCommand, UnflagClientCommand>()
|
||||||
.AddSingleton<IManagerCommand, SayCommand>()
|
.AddSingleton<IManagerCommand, SayCommand>()
|
||||||
|
.AddSingleton<IManagerCommand, SetLevelCommand>()
|
||||||
.BuildServiceProvider()
|
.BuildServiceProvider()
|
||||||
.SetupTestHooks();
|
.SetupTestHooks();
|
||||||
|
|
||||||
@ -141,6 +142,19 @@ namespace ApplicationTests
|
|||||||
Assert.AreEqual(expectedEndpoint, result.RouteValues["serverId"]);
|
Assert.AreEqual(expectedEndpoint, result.RouteValues["serverId"]);
|
||||||
Assert.AreEqual(expectedCommandText, result.RouteValues["command"]);
|
Assert.AreEqual(expectedCommandText, result.RouteValues["command"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task Test_SetLevel_Redirects_WithCommandText()
|
||||||
|
{
|
||||||
|
var controller = serviceProvider.GetRequiredService<ActionController>();
|
||||||
|
var expectedCommandText = "!setlevel @1 Moderator";
|
||||||
|
var expectedEndpoint = server.EndPoint;
|
||||||
|
|
||||||
|
var result = await controller.EditAsync(1, "Moderator") as RedirectToActionResult;
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedEndpoint, result.RouteValues["serverId"]);
|
||||||
|
Assert.AreEqual(expectedCommandText, result.RouteValues["command"]);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ namespace WebfrontCore.Controllers
|
|||||||
private readonly string _kickCommandName;
|
private readonly string _kickCommandName;
|
||||||
private readonly string _flagCommandName;
|
private readonly string _flagCommandName;
|
||||||
private readonly string _unflagCommandName;
|
private readonly string _unflagCommandName;
|
||||||
|
private readonly string _setLevelCommandName;
|
||||||
|
|
||||||
public ActionController(IManager manager, IEnumerable<IManagerCommand> registeredCommands) : base(manager)
|
public ActionController(IManager manager, IEnumerable<IManagerCommand> registeredCommands) : base(manager)
|
||||||
{
|
{
|
||||||
@ -55,6 +56,9 @@ namespace WebfrontCore.Controllers
|
|||||||
case nameof(UnflagClientCommand):
|
case nameof(UnflagClientCommand):
|
||||||
_unflagCommandName = cmd.Name;
|
_unflagCommandName = cmd.Name;
|
||||||
break;
|
break;
|
||||||
|
case nameof(SetLevelCommand):
|
||||||
|
_setLevelCommandName = cmd.Name;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +234,7 @@ namespace WebfrontCore.Controllers
|
|||||||
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
|
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
|
||||||
{
|
{
|
||||||
serverId = server.EndPoint,
|
serverId = server.EndPoint,
|
||||||
command = $"{_appConfig.CommandPrefix}setlevel @{targetId} {level}"
|
command = $"{_appConfig.CommandPrefix}{_setLevelCommandName} @{targetId} {level}"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ namespace WebfrontCore
|
|||||||
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IAuditInformationRepository>());
|
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IAuditInformationRepository>());
|
||||||
services.AddSingleton(Program.ApplicationServiceProvider.GetService<ITranslationLookup>());
|
services.AddSingleton(Program.ApplicationServiceProvider.GetService<ITranslationLookup>());
|
||||||
services.AddSingleton(Program.ApplicationServiceProvider.GetService<SharedLibraryCore.Interfaces.ILogger>());
|
services.AddSingleton(Program.ApplicationServiceProvider.GetService<SharedLibraryCore.Interfaces.ILogger>());
|
||||||
|
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IEnumerable<IManagerCommand>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
Loading…
Reference in New Issue
Block a user