Пример #1
0
        /// <summary>Main entry point into the test harness.</summary>
        public static void Main()
        {
            string logFileName = "Log_" + DateTime.Now.ToShortDateString() + ".txt";

            logFileName = logFileName.Replace('\\', '_').Replace('/', '_');
            var consoleDisplay = new ConsoleUpdater();
            var textLogWriter  = new TextLogUpdater(logFileName);
            var display        = new MultiUpdater(consoleDisplay, textLogWriter);

            var app = Application.Instance;

            app.SubscribeToSystem(display);

            app.Start();

            // TODO: Consider reflecting implementers of ITestHarnessCommand to keep this automatically up to date?
            ITestHarnessCommand[] commandObjects = { new HelpCommand(), new UpdateActionsCommand(), new RunTestsCommand() };
            IDictionary <string, ITestHarnessCommand> commands = new ConcurrentDictionary <string, ITestHarnessCommand>();

            foreach (var cmdObj in commandObjects)
            {
                foreach (var name in cmdObj.Names)
                {
                    commands[name] = cmdObj;
                }
            }

            var input = string.Empty;

            while (true)
            {
                input = Console.ReadLine();
                if (input != null)
                {
                    // TODO: Console.ReadLine probably never includes newlines; this code is probably not doing what was intended!
                    string[] words = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    if (words.Length == 0)
                    {
                        continue;
                    }
                    else if ("shutdown".Equals(input, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }

                    var cmd = words[0];
                    if (commands.ContainsKey(cmd))
                    {
                        commands[cmd].Execute(app, display, words);
                    }
                    else
                    {
                        display.Notify(string.Format("> Command Not Recognized. [{0}]", string.Join(" ", words)));
                    }
                }

                // This is for Mono compatability.
                input = string.Empty;
            }

            app.Stop();

            display.Notify("Press enter to quit...");
            Console.ReadLine();
        }
Пример #2
0
        /// <summary>Main entry point into the test harness.</summary>
        public static void Main()
        {
            string logFileName = "Log_" + DateTime.Now.ToShortDateString() + ".txt";
            logFileName = logFileName.Replace('\\', '_').Replace('/', '_');
            var consoleDisplay = new ConsoleUpdater();
            var textLogWriter = new TextLogUpdater(logFileName);
            var display = new MultiUpdater(consoleDisplay, textLogWriter);

            var app = Application.Instance;

            app.SubscribeToSystem(display);

            app.Start();

            // TODO: Consider reflecting implementers of ITestHarnessCommand to keep this automatically up to date?
            ITestHarnessCommand[] commandObjects = { new HelpCommand(), new UpdateActionsCommand(), new RunTestsCommand() };
            IDictionary<string, ITestHarnessCommand> commands = new ConcurrentDictionary<string, ITestHarnessCommand>();

            foreach (var cmdObj in commandObjects)
            {
                foreach (var name in cmdObj.Names)
                {
                    commands[name] = cmdObj;
                }
            }

            var input = string.Empty;

            while (true)
            {
                input = Console.ReadLine();
                if (input != null)
                {
                    // TODO: Console.ReadLine probably never includes newlines; this code is probably not doing what was intended!
                    string[] words = input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    if (words.Length == 0)
                    {
                        continue;
                    }
                    else if ("shutdown".Equals(input, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }

                    var cmd = words[0];
                    if (commands.ContainsKey(cmd))
                    {
                        commands[cmd].Execute(app, display, words);
                    }
                    else
                    {
                        display.Notify(string.Format("> Command Not Recognized. [{0}]", string.Join(" ", words)));
                    }
                }

                // This is for Mono compatability.
                input = string.Empty;
            }

            app.Stop();

            display.Notify("Press enter to quit...");
            Console.ReadLine();
        }