Skip to content
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

Print commas at the end of the line #1945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Formatting/DefaultValueFormatter.cs
Expand Up @@ -42,7 +42,7 @@ public void Format(object value, FormattedObjectGraph formattedGraph, Formatting
{
if (context.UseLineBreaks)
{
formattedGraph.AddLine(value.ToString());
formattedGraph.AddFragmentOnNewLine(value.ToString());
}
else
{
Expand Down
14 changes: 14 additions & 0 deletions Tests/FluentAssertions.Specs/Formatting/FormatterSpecs.cs
Expand Up @@ -653,6 +653,20 @@ public void When_formatting_a_large_dictionary_it_should_limit_the_number_of_for
result.Should().Match("*…18 more…*");
}

[Fact]
public void When_formatting_multiple_items_with_a_custom_string_representation_using_line_breaks_it_should_end_lines_with_a_comma()
{
// Arrange
var subject = new[] { typeof(A), typeof(B) };

// Act
string result = Formatter.ToString(subject, new FormattingOptions { UseLineBreaks = true } );

// Assert
result.Should().Contain($"FluentAssertions.Specs.Formatting.FormatterSpecs+A, {Environment.NewLine}");
result.Should().Contain($"FluentAssertions.Specs.Formatting.FormatterSpecs+B{Environment.NewLine}");
}

public class BaseStuff
{
public int StuffId { get; set; }
Expand Down