public void Formatter_does_not_expand_properties_of_PocketView(string mimeType) { PocketView view = b(123); view.ToDisplayString(mimeType).Should().Be($"<b>{PlainTextBegin}123{PlainTextEnd}</b>"); }
public void Formatter_does_not_expand_properties_of_PocketView(string mimeType) { PocketView view = b(123); view.ToDisplayString(mimeType).Should().Be("<b>123</b>"); }
private static void SetupRecordFormatters() { // DebugRecord Formatter <DebugRecord> .Register((record, writer) => { PocketView view = pre($"DEBUG: {record.Message}"); writer.WriteLine(view.ToDisplayString(HtmlFormatter.MimeType)); }, HtmlFormatter.MimeType); Formatter <DebugRecord> .Register((record, writer) => { writer.WriteLine($"DEBUG: {record.Message}"); }, PlainTextFormatter.MimeType); // ErrorRecord Formatter <ErrorRecord> .Register((record, writer) => { string result = null; lock (_pwshLock) { var errorDetails = _pwsh.AddCommand("Microsoft.PowerShell.Utility\\Out-String") .AddParameter("InputObject", record) .InvokeAndClearCommands <string>(); result = errorDetails.Single(); } if (result != null) { PocketView view = pre(result.Trim()); writer.WriteLine(view.ToDisplayString(HtmlFormatter.MimeType)); } }, HtmlFormatter.MimeType); Formatter <ErrorRecord> .Register((record, writer) => { string result = null; lock (_pwshLock) { var errorDetails = _pwsh.AddCommand("Microsoft.PowerShell.Utility\\Out-String") .AddParameter("InputObject", record) .InvokeAndClearCommands <string>(); result = errorDetails.Single(); } if (result != null) { writer.WriteLine(result.Trim()); } }, PlainTextFormatter.MimeType); // InformationRecord Formatter <InformationRecord> .Register((record, writer) => { string prefix = (record.Tags.Count == 1 && (record.Tags[0] == "__PipelineObject__" || record.Tags[0] == "PSHOST")) ? "" : "INFORMATION: "; PocketView view = pre($"{prefix}{record.MessageData}"); writer.WriteLine(view.ToDisplayString(HtmlFormatter.MimeType)); }, HtmlFormatter.MimeType); Formatter <InformationRecord> .Register((record, writer) => { string prefix = (record.Tags.Count == 1 && (record.Tags[0] == "__PipelineObject__" || record.Tags[0] == "PSHOST")) ? "" : "INFORMATION: "; writer.WriteLine($"{prefix}{record.MessageData}"); }, PlainTextFormatter.MimeType); // ProgressRecord Formatter <ProgressRecord> .Register((record, writer) => { PocketView view = pre($"PROGRESS: {record.StatusDescription}"); writer.WriteLine(view.ToDisplayString(HtmlFormatter.MimeType)); }, HtmlFormatter.MimeType); Formatter <ProgressRecord> .Register((record, writer) => { writer.WriteLine($"PROGRESS: {record.StatusDescription}"); }, PlainTextFormatter.MimeType); // VerboseRecord Formatter <VerboseRecord> .Register((record, writer) => { PocketView view = pre($"VERBOSE: {record.Message}"); writer.WriteLine(view.ToDisplayString(HtmlFormatter.MimeType)); }, HtmlFormatter.MimeType); Formatter <VerboseRecord> .Register((record, writer) => { writer.WriteLine($"VERBOSE: {record.Message}"); }, PlainTextFormatter.MimeType); // WarningRecord Formatter <WarningRecord> .Register((record, writer) => { PocketView view = pre($"WARNING: {record.Message}"); writer.WriteLine(view.ToDisplayString(HtmlFormatter.MimeType)); }, HtmlFormatter.MimeType); Formatter <WarningRecord> .Register((record, writer) => { writer.WriteLine($"WARNING: {record.Message}"); }, PlainTextFormatter.MimeType); }