Ejemplo n.º 1
0
        private static void ConfigureProcessTaskForLogging(ProcessTask task, MarkupStreamWriter writer)
        {
            task.Started += delegate
            {
                writer.BeginSection(String.Format("Run Process: {0} {1}", task.ExecutablePath, task.Arguments));
                writer.WriteLine("Working Directory: {0}", task.WorkingDirectory);
                writer.BeginMarker(Marker.Monospace);
            };

            task.ConsoleOutputDataReceived += delegate(object sender, DataReceivedEventArgs e)
            {
                if (e.Data != null)
                    writer.WriteLine(e.Data);
            };

            task.ConsoleErrorDataReceived += delegate(object sender, DataReceivedEventArgs e)
            {
                if (e.Data != null)
                    writer.WriteLine(e.Data);
            };

            task.Aborted += delegate
            {
                if (task.IsRunning)
                    writer.BeginSection("Abort requested.  Killing the process!").Dispose();
            };

            task.Terminated += delegate
            {
                writer.End();
                writer.WriteLine("Exit Code: {0}", task.ExitCode);
                writer.End();
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes the details about the assertion failure to the structured text writer.
        /// </summary>
        /// <param name="writer">The structured text writer, not null.</param>
        protected virtual void WriteDetails(MarkupStreamWriter writer)
        {
            if (!string.IsNullOrEmpty(message))
                writer.WriteLine(message);

            if (labeledValues.Count != 0)
            {
                writer.WriteLine();

                using (writer.BeginMarker(Marker.Monospace))
                {
                    int paddedLength = ComputePaddedLabelLength();
                    foreach (LabeledValue labeledValue in labeledValues)
                    {
                        WriteLabel(writer, labeledValue.Label, paddedLength);
                        WriteFormattedValue(writer, labeledValue.FormattedValue);
                        writer.WriteLine();
                    }
                }
            }

            if (exceptions.Count != 0)
            {
                foreach (ExceptionData exception in exceptions)
                {
                    writer.WriteLine();
                    writer.WriteException(exception);
                    writer.WriteLine();
                }
            }

            if (stackTrace != null && !stackTrace.IsEmpty)
            {
                writer.WriteLine();
                stackTrace.WriteTo(writer);
                writer.WriteLine();
            }
        }