public void Write() { Command command = new EmptyCommand(); var context = new Context(); var writer = new StringWriter(); context.Output = writer; command.Context = context; command.Execute(); var expected = string.Format("12{0}3{0}", Environment.NewLine); Assert.AreEqual(expected, writer.ToString()); }
public static int Main(string[] args) { var app = new CommandLineApplication { Name = "Geek Cafe AWS CDK DevOps CLI", Description = "Wrapper for AWS CDK" }; var options = new Commands.Options.Common(); options.Register(app, ""); // register the commands app.RegisterCommands(); // app.OnExecute(() => { // if we get here then a registered command wasn't found // so we can run the default var cmd = new EmptyCommand(options); var result = cmd.Execute(); if (result == (int)ExitCodes.MISSING_OPTIONS) { app.ShowHelp(); } return(result); }); var exitCode = 0; try { // attempt to execute a command based on what we registred above Utilities.Logger.Log($"{app.Name} starting exection."); exitCode = app.Execute(args); Utilities.Logger.Log($"{app.Name} executed successfully."); } catch (Exception ex) { // something bad happened Utilities.Logger.Log($"{app.Name} executed with errors."); Utilities.Logger.Log($"Fatel Exception {ex.Message}"); exitCode = (int)ExitCodes.FATEL_ERROR; } return(exitCode); }
public void CheckPendingCancelTest() { _context.Log.SetPendingCancel(); try { _testCommand.Execute(_context); Assert.IsFalse(true); } catch (Exception ex) { Assert.IsInstanceOf(typeof(PackageExecutionCancelledException), ex); } }
public void Execute() { Command command = new EmptyCommand(); Assert.AreEqual(0, command.Execute()); }