public void LoadAllCommandsTest() { var commands = MiscHelpers.LoadAllCommands(); commands.Count.Should().Equals(10); commands.Select(c => c.Module).Distinct().Count().Should().Equals(3); }
public void SetParamsTest() { var testCommand = PrepareTestCommand(); var commands = MiscHelpers.LoadAllCommands(); MiscHelpers.ResolveCommand(commands, testCommand); var cmd = Activator.CreateInstance(testCommand.Type); MiscHelpers.SetParams(cmd, testCommand); var expected = new Rhetos { AppPoolName = "vlado_test", DataBaseName = "vlado_test_vladimir", DBPassword = "******", DBServer = "ADSQL2008R2\\ADSQL2012", DBUserName = "******", Password = "******", RhetosVersion = "v2.7.0", SiteName = "vlado_test", UserName = "******", UseWindowsAuth = true }; cmd.Should().BeEquivalentTo(expected); }
public void ResolveCommandTest() { var testCommand = PrepareTestCommand(); var commands = MiscHelpers.LoadAllCommands(); MiscHelpers.ResolveCommand(commands, testCommand); testCommand.Module.Should().Equals("rhetos"); testCommand.Type.ToString().Should().Equals(typeof(Rhetos).ToString()); }
private static void Main(string[] args) { try { Logging.Logger = LogManager.GetCurrentClassLogger(); Logging.LogInfo("Rhetos CLI version {0}", Assembly.GetExecutingAssembly().GetName().Version); CreateCacheFolder(); var commands = MiscHelpers.LoadAllCommands(); var command = MiscHelpers.ParseCommandLine(args); if (string.Equals(command.Module, "help", StringComparison.OrdinalIgnoreCase)) { Logging.LogInfo("Usage RhetosCli [Module] [Command] [Parameters]"); Logging.LogInfo("For help use RhetosCli help or RhetosCli [module] help"); } else { if (MiscHelpers.ResolveCommand(commands, command)) { var cmd = Activator.CreateInstance(command.Type); MiscHelpers.SetParams(cmd, command); var methodInfo = cmd.GetType().GetMethod(command.Method); methodInfo.Invoke(cmd, null); } else { Logging.LogFatal("Invalid command specified. Aborting."); Logging.LogInfo("Usage RhetosCli [Module] [Command] [Parameters]"); Logging.LogInfo("For help use RhetosCli help or RhetosCli [module] help"); } } } catch (Exception ex) { Logging.LogFatal(ex, ""); } finally { MiscHelpers.WriteLine("Press key to exit "); if (MiscHelpers.IsInteractive()) { Console.ReadKey(); } } }