Example #1
0
        static void Main(string[] args)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

            Utility.InitializeUtf(assembly.GetName().Name);

            ProgramSwitches switches = ProcessArguments(args);

            if (switches.ShowHelp)
            {
                // ShowUsage();
            }
            else
            {
                TestSuite suite = (TestSuite)Utility.BuildTestSuiteMatching(
                    assembly,
                    Environment.CommandLine,
                    (string[])switches.NonSwitchArgs.ToArray(typeof(string)),
                    switches.ExactMatch);
                suite.Execute();
            }
        }
Example #2
0
        private static ProgramSwitches ProcessArguments(string[] args)
        {
            ProgramSwitches switches = new ProgramSwitches();

            foreach (string argument in args)
            {
                if (!String.IsNullOrEmpty(argument))
                {
                    if ((argument.Length > 1) && ((argument[0] == '/') || (argument[0] == '-')))
                    {
                        string[] subArguments = argument.Split(new char[] { ':' }, 2);
                        // Note: subArguments length is assured to be greater than 1.
                        switch (subArguments[0].Substring(1).ToLower(CultureInfo.InvariantCulture))
                        {
                        case "?":
                            switches.ShowHelp = true;
                            break;

                        case "f1perf":
                            switches.F1Profiling = true;
                            if (subArguments.Length > 1)
                            {
                                switches.PerformanceProcess = subArguments[1];
                            }
                            if (switches.OfficeProfiling)     // only one of the performance profiler can be enabled
                            {
                                switches.ShowHelp = true;
                            }
                            break;

                        case "offperf":
                            switches.OfficeProfiling = true;
                            if (subArguments.Length > 1)
                            {
                                switches.PerformanceProcess = subArguments[1];
                            }
                            if (switches.F1Profiling)     // only one of the performance profiler can be enabled
                            {
                                switches.ShowHelp = true;
                            }
                            break;

                        case "crmplatformprofiling":
                            switches.CrmPlatformProfiling = true;
                            break;

                        case "starttime":
                            Console.WriteLine("Current Time: " + DateTime.Now.ToLongTimeString());
                            if (subArguments.Length > 1)
                            {
                                switches.StartTime = Convert.ToDateTime(subArguments[1], CultureInfo.CurrentCulture.DateTimeFormat);
                            }
                            break;

                        case "exactmatch":
                            switches.ExactMatch = true;
                            break;

                        default:
                            // Unrecognized switch, do nothing
                            break;
                        }
                    }
                    else
                    {
                        switches.NonSwitchArgs.Add(argument);
                    }
                }
            }

            return(switches);
        }