From 305817d00c497b8f0601b43b28b3678e28c82fa3 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Fri, 12 Oct 2018 21:28:22 -0500 Subject: [PATCH] version 2.2 stable --- Application/Main.cs | 4 ++++ Application/Manager.cs | 3 --- Application/Migration/ConfigurationMigration.cs | 6 +++--- IW4MAdmin.sln | 1 + Plugins/Tests/ManagerFixture.cs | 5 ++++- Plugins/Tests/ManagerTests.cs | 16 ++++++++++++++++ 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Application/Main.cs b/Application/Main.cs index 358dc478b..701a67cbe 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading; using System.Collections.Generic; using SharedLibraryCore.Localization; +using IW4MAdmin.Application.Migration; namespace IW4MAdmin.Application { @@ -42,6 +43,9 @@ namespace IW4MAdmin.Application Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey); CheckDirectories(); + // do any needed migrations + // todo: move out + ConfigurationMigration.MoveConfigFolder10518(null); ServerManager = ApplicationManager.GetInstance(); Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration()?.CustomLocale); diff --git a/Application/Manager.cs b/Application/Manager.cs index b34241aa5..dd5e98ce9 100644 --- a/Application/Manager.cs +++ b/Application/Manager.cs @@ -53,9 +53,6 @@ namespace IW4MAdmin.Application private ApplicationManager() { - // do any needed migrations - // todo: move out - ConfigurationMigration.MoveConfigFolder10518(Logger); _servers = new List(); Commands = new List(); TaskStatuses = new List(); diff --git a/Application/Migration/ConfigurationMigration.cs b/Application/Migration/ConfigurationMigration.cs index ae20113b8..496aa2e55 100644 --- a/Application/Migration/ConfigurationMigration.cs +++ b/Application/Migration/ConfigurationMigration.cs @@ -30,7 +30,7 @@ namespace IW4MAdmin.Application.Migration if (!Directory.Exists(configDirectory)) { - log.WriteDebug($"Creating directory for configs {configDirectory}"); + log?.WriteDebug($"Creating directory for configs {configDirectory}"); Directory.CreateDirectory(configDirectory); } @@ -40,7 +40,7 @@ namespace IW4MAdmin.Application.Migration foreach (var configFile in configurationFiles) { - log.WriteDebug($"Moving config file {configFile}"); + log?.WriteDebug($"Moving config file {configFile}"); string destinationPath = Path.Join("Configuration", configFile); if (!File.Exists(destinationPath)) { @@ -51,7 +51,7 @@ namespace IW4MAdmin.Application.Migration if (!File.Exists(Path.Join("Database", "Database.db")) && File.Exists("Database.db")) { - log.WriteDebug("Moving database file"); + log?.WriteDebug("Moving database file"); File.Move("Database.db", Path.Join("Database", "Database.db")); } } diff --git a/IW4MAdmin.sln b/IW4MAdmin.sln index efe8e8387..dbb34eeb0 100644 --- a/IW4MAdmin.sln +++ b/IW4MAdmin.sln @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution _customcallbacks.gsc = _customcallbacks.gsc README.md = README.md RunPublishPre.cmd = RunPublishPre.cmd + RunPublishRelease.cmd = RunPublishRelease.cmd version.txt = version.txt EndProjectSection EndProject diff --git a/Plugins/Tests/ManagerFixture.cs b/Plugins/Tests/ManagerFixture.cs index 557d257a9..e8dca5a34 100644 --- a/Plugins/Tests/ManagerFixture.cs +++ b/Plugins/Tests/ManagerFixture.cs @@ -18,7 +18,9 @@ namespace Tests { File.WriteAllText("test_mp.log", "test_log_file"); - Manager = Program.ServerManager; + IW4MAdmin.Application.Localization.Configure.Initialize("en-US"); + + Manager = ApplicationManager.GetInstance(); var config = new ApplicationConfiguration { @@ -43,6 +45,7 @@ namespace Tests Manager.ConfigHandler.Set(config); Manager.Init().Wait(); + Task.Run(() => Manager.Start()); } diff --git a/Plugins/Tests/ManagerTests.cs b/Plugins/Tests/ManagerTests.cs index 4e8f447eb..1f8a1a7be 100644 --- a/Plugins/Tests/ManagerTests.cs +++ b/Plugins/Tests/ManagerTests.cs @@ -188,6 +188,22 @@ namespace Tests resetEvent.Wait(5000); } + + [Fact] + public void PrintCommands() + { + var sb = new StringBuilder(); + + sb.AppendLine("|Name |Alias|Description |Requires Target|Syntax |Required Level|"); + sb.AppendLine("|--------------| -----| --------------------------------------------------------| -----------------| -------------| ----------------|"); + + foreach (var command in Manager.GetCommands().OrderByDescending(c => c.Permission).ThenBy(c => c.Name)) + { + sb.AppendLine($"|{command.Name}|{command.Alias}|{command.Description}|{command.RequiresTarget}|{command.Syntax.Substring(8).EscapeMarkdown()}|{command.Permission}|"); + } + + Assert.True(false, sb.ToString()); + } } }