Beispiel #1
0
        protected override Task Run(ArgAction toRun)
        {
            ConsoleOutInterceptor.Instance.Attach();
            toRun.Invoke();
            var output = ConsoleOutInterceptor.Instance.ReadAndClear();

            ConsoleOutInterceptor.Instance.Detatch();
            WriteLine(new ConsoleString(output));
            return(Task.CompletedTask);
        }
Beispiel #2
0
        public void ArgActionInvokeThrowsOnNullAction()
        {
            var args      = new string[] { };
            var argAction = new ArgAction <ActionTestArgs>();

            // Not setting .ActionArgs or .Args to leave them as null.

            try
            {
                argAction.Invoke();
                Assert.Fail("Should have thrown an exception.");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(MissingArgException));
                Assert.AreEqual("No action was specified", ex.Message);
            }
        }
Beispiel #3
0
        public void ArgActionInvokeThrowsOnNullAction()
        {
            var args = new string[] { };
            var argAction = new ArgAction<ActionTestArgs>();

            // Not setting .ActionArgs or .Args to leave them as null.

            try
            {
                argAction.Invoke();
                Assert.Fail("Should have thrown an exception.");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(MissingArgException));
                Assert.AreEqual("No action was specified", ex.Message);
            }
        }
Beispiel #4
0
 protected virtual Task <ConsoleString> Run(ArgAction toRun)
 {
     toRun.Invoke();
     return(Task.FromResult("Command finished".ToCyan()));
 }
Beispiel #5
0
 protected virtual Task Run(ArgAction toRun)
 {
     toRun.Invoke();
     WriteLine("Command finished".ToCyan());
     return(Task.CompletedTask);
 }
Beispiel #6
0
 protected virtual Task Run(ArgAction toRun)
 {
     toRun.Invoke();
     SetOutput(null);
     return(Task.CompletedTask);
 }