Пример #1
0
        public ProcessOutput ExecuteTest()
        {
            lock (_executing)
            {
                Log.Close();
                Log.Open();
                Log.Info("enter");

                SaveTempOptions();
                ConfigurationOptions config    = new ConfigurationOptions(TempArgs, true);
                Collector            collector = new Collector();
                Assert.IsNotNull(collector);

                StartConsoleRedirection();
                Log.Info(">>>>Starting test<<<<\r\n", ConfigurationOptions);
                // cant call with args
                //
                // populate default collectsfdata.options.json
                int result = collector.Collect();
                //int result = program.Collect(new string[] { });

                Log.Info(">>>>test result<<<<", result);
                ProcessOutput output = StopConsoleRedirection();

                Assert.IsNotNull(output);

                if (result != 0)
                {
                    Log.Error($"result {result}");
                    output.ExitCode = result;
                }

                WriteConsole($">>>>test result<<<<", output);
                return(output);
            }
        }
Пример #2
0
        public ProcessOutput StopConsoleRedirection()
        {
            Log.Info("stopping redirection");
            // give time for logging to finish
            Thread.Sleep(1000);
            Log.Close();
            FlushConsoleOutput();
            ProcessOutput output = new ProcessOutput
            {
                StandardError  = ConsoleErr.ToString(),
                StandardOutput = ConsoleOut.ToString()
            };

            ConsoleErr = new StringWriter();
            ConsoleOut = new StringWriter();

            Console.SetOut(Console.Out);
            Console.SetError(Console.Error);

            consoleOutBuilder.Append(output.StandardOutput);
            consoleErrBuilder.Append(output.StandardError);

            return(output);
        }
Пример #3
0
        public ProcessOutput ExecuteTest <T>(Func <T, bool> func, T input)
        {
            LogMessageQueueEnabled = false;
            Log.Close();
            Log.Open();

            LogMessageQueueEnabled = true;
            Log.Info("enter");

            StartConsoleRedirection();
            Log.Info(">>>>Starting test<<<<\r\n", ConfigurationOptions);

            var result = func(input);

            Log.Close();
            LogMessageQueueEnabled = false;

            Log.Info(">>>>test result<<<<", result);
            ProcessOutput output = StopConsoleRedirection();

            output.LogMessages = LogMessageQueue.ToList();
            LogMessageQueue.Clear();
            Assert.IsNotNull(output);

            Log.Error($"result {result}");

            output.ExitCode = Convert.ToInt32(result);
            output.ExitBool = Convert.ToBoolean(result);
            if (!output.ExitBool)
            {
                output.ExitCode = -1;
            }

            WriteConsole($">>>>test result<<<<", output);
            return(output);
        }