예제 #1
0
        /// <summary>
        /// Runs the command application and expects an exception of a specific type to be thrown.
        /// </summary>
        /// <typeparam name="T">The expected exception type.</typeparam>
        /// <param name="args">The arguments.</param>
        /// <returns>The information about the failure.</returns>
        public CommandAppFailure RunAndCatch <T>(params string[] args)
            where T : Exception
        {
            var console = new TestConsole().Width(int.MaxValue);

            try
            {
                Run(args, console, c => c.PropagateExceptions());
                throw new InvalidOperationException("Expected an exception to be thrown, but there was none.");
            }
            catch (T ex)
            {
                if (ex is CommandAppException commandAppException && commandAppException.Pretty != null)
                {
                    console.Write(commandAppException.Pretty);
                }
 public void Write(IRenderable renderable) => SpectreTestConsole.Write(renderable);