static void Main(string[] args)
        {
            ICommandParser    parser    = new CommandLineParser();
            ICommandValidator validator = new CommandLineValidator();
            IHandler          handler   = new SimpleHandler(parser, validator);

            while (true)
            {
                Console.Write("enter command: ");
                var line = Console.ReadLine();

                try
                {
                    handler.Handle(line);
                    Console.WriteLine(handler.CurrentSheet?.ToString());
                }
                catch (CommandTypeException ex)
                {
                    Console.WriteLine("CommandType error: " + ex.Message);
                }
                catch (ValidationException ex)
                {
                    Console.WriteLine("Validation error: " + ex.Message);
                }
                catch (QuitProgramException)
                {
                    Console.WriteLine("Finished...");
                    break;
                }
            }

#if DEBUG
            Console.ReadLine();
#endif
        }
Example #2
0
        /// <summary>
        /// Remove '-',whitespace and change '?' alias to its internal real option name 'help'
        /// </summary>
        /// <returns></returns>
        internal static bool Test2()
        {
            CommandLineValidator cmdValidator = new CommandLineValidator();

            string[] args = new string[] { " -? " };
            cmdValidator.ValidateCommandLineArguments(ref args);
            if (args[0] == "help")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// Try to set /unregfile with invalid arguments
        /// </summary>
        /// <returns></returns>
        internal static bool Test4()
        {
            CommandLineValidator cmdValidator = new CommandLineValidator();

            string[] args = new string[] { "C:\\MyFile.dll", "/unregfile:C:\\MyFile.reg" };

            try
            {
                cmdValidator.ValidateCommandLineArguments(ref args);
                return(false);
            }
            catch (RegAddinException)
            {
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Try to give an unkown option
        /// </summary>
        /// <returns></returns>
        internal static bool Test1()
        {
            CommandLineValidator cmdValidator = new CommandLineValidator();

            string[] args = new string[] { " /foo " };

            try
            {
                cmdValidator.ValidateCommandLineArguments(ref args);
                return(false);
            }
            catch (RegAddinException)
            {
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public void TestParseCommandLine9()
 {
     Assert.IsFalse(CommandLineValidator.IsCommandLineValid(new[] { "-osjfjs" }));
 }
 public void TestParseCommandLine7()
 {
     Assert.IsFalse(CommandLineValidator.IsCommandLineValid(new[] { "osjfjs", "lskfjjf", "sfjdskdf" }));
 }
 public void TestParseCommandLine6()
 {
     Assert.IsFalse(CommandLineValidator.IsCommandLineValid(new[] { "-cw:ssid", "-cw:pwd" }));
 }
 public void TestParseCommandLine4()
 {
     Assert.IsFalse(CommandLineValidator.IsCommandLineValid(new[] { "-ea", "-ca" }));
 }
 public void TestParseCommandLine3()
 {
     Assert.IsFalse(CommandLineValidator.IsCommandLineValid(new[] { "asdlkfjlasd;kfjs;lakdfj" }));
 }