コード例 #1
0
        private void ExecTestCommandsI(List <TestCommand> testCommands)
        {
            DebugLog("testCommands: {0}", testCommands);

            var stopwatch = new Stopwatch();

            foreach (var testCommand in testCommands)
            {
                stopwatch.Restart();

                DebugLog("ClassName: {0}, FunctionName: {1}", testCommand.ClassName, testCommand.FunctionName);
                if (testCommand.Params != null && testCommand.Params.Count > 0)
                {
                    DebugLog("Params:");
                    foreach (var entry in testCommand.Params)
                    {
                        DebugLog("\t{0}: {1}", entry.Key, string.Join(", ", entry.Value));
                    }
                }

                DebugLog("time before {0} {1}: {2}", testCommand.ClassName, testCommand.FunctionName,
                         DateTime.Now.ToString(DATE_TIME_FORMAT));

                if (Constants.TEST_LIBRARY_CLASSNAME == testCommand.ClassName)
                {
                    ExecuteTestLibraryCommandI(testCommand);
                    DebugLog("time after {0} {1}: {2}", testCommand.ClassName, testCommand.FunctionName,
                             DateTime.Now.ToString(DATE_TIME_FORMAT));
                    DebugLog("time elapsed {0} {1} in milli seconds: {2}", testCommand.ClassName,
                             testCommand.FunctionName, stopwatch.ElapsedMilliseconds);

                    continue;
                }

                if (CommandListener != null)
                {
                    CommandListener.ExecuteCommand(testCommand.ClassName, testCommand.FunctionName,
                                                   testCommand.Params);
                }
                else if (CommandJsonListener != null)
                {
                    CommandJsonListener.ExecuteCommand(testCommand.ClassName, testCommand.FunctionName, JsonConvert.SerializeObject(testCommand.Params));
                }
                else if (CommandRawJsonListener != null)
                {
                    CommandRawJsonListener.ExecuteCommand(JsonConvert.SerializeObject(testCommand));
                }

                DebugLog("time after {0}.{1}: {2}", testCommand.ClassName, testCommand.FunctionName,
                         DateTime.Now.ToString(DATE_TIME_FORMAT));
                DebugLog("time elapsed {0}.{1} in milli seconds: {2}", testCommand.ClassName, testCommand.FunctionName,
                         stopwatch.ElapsedMilliseconds);
            }
        }