Skip to content

V2 API Review #1674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bunit/Diffing/DiffMarkupFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Bunit.Diffing;
/// <summary>
/// A markup formatter, that skips any special Blazor attributes added by the <see cref="Htmlizer"/>.
/// </summary>
public class DiffMarkupFormatter : PrettyMarkupFormatter, IMarkupFormatter
internal class DiffMarkupFormatter : PrettyMarkupFormatter, IMarkupFormatter
{
/// <summary>
/// Initializes a new instance of the <see cref="DiffMarkupFormatter"/> class.
Expand Down
53 changes: 1 addition & 52 deletions src/bunit/Extensions/NodePrintExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Bunit;
/// <summary>
/// Helper methods for pretty printing markup from <see cref="INode"/> and <see cref="INodeList"/>.
/// </summary>
public static class NodePrintExtensions
internal static class NodePrintExtensions
{
/// <summary>
/// Writes the serialization of the node guided by the formatter.
Expand All @@ -28,21 +28,6 @@ public static void ToHtml(this IEnumerable<INode> nodes, TextWriter writer, IMar
}
}

/// <summary>
/// Uses the <see cref="DiffMarkupFormatter"/> to generate a HTML markup string
/// from a <see cref="IEnumerable{INode}"/> <paramref name="nodes"/>.
/// The generated HTML markup will NOT include the internal Blazor attributes
/// added to elements.
/// </summary>
public static string ToDiffMarkup(this IEnumerable<INode> nodes)
{
ArgumentNullException.ThrowIfNull(nodes);

using var sw = new StringWriter();
nodes.ToHtml(sw, new DiffMarkupFormatter());
return sw.ToString();
}

/// <summary>
/// Uses the <see cref="DiffMarkupFormatter"/> to generate a HTML markup string
/// from a <see cref="IMarkupFormattable"/> <paramref name="markupFormattable"/>.
Expand All @@ -58,42 +43,6 @@ public static string ToDiffMarkup(this IMarkupFormattable markupFormattable)
return sw.ToString();
}

/// <summary>
/// Uses the <see cref="PrettyMarkupFormatter"/> to generate a HTML markup string
/// from a <see cref="IEnumerable{INode}"/> <paramref name="nodes"/>.
/// </summary>
public static string ToMarkup(this IEnumerable<INode> nodes)
{
ArgumentNullException.ThrowIfNull(nodes);

using var sw = new StringWriter();
var formatter = new PrettyMarkupFormatter
{
NewLine = Environment.NewLine,
Indentation = " ",
};
nodes.ToHtml(sw, formatter);
return sw.ToString();
}

/// <summary>
/// Uses the <see cref="PrettyMarkupFormatter"/> to generate a HTML markup
/// from a <see cref="IMarkupFormattable"/> <paramref name="markupFormattable"/>.
/// </summary>
public static string ToMarkup(this IMarkupFormattable markupFormattable)
{
ArgumentNullException.ThrowIfNull(markupFormattable);

using var sw = new StringWriter();
var formatter = new PrettyMarkupFormatter
{
NewLine = Environment.NewLine,
Indentation = " ",
};
markupFormattable.ToHtml(sw, formatter);
return sw.ToString();
}

/// <summary>
/// Converts an <see cref="IElement"/> into a HTML markup string,
/// with only its tag and attributes included in the output. All
Expand Down