| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Test Results 37 files ± 0 37 suites ±0 2m 43s ⏱️ -22s Results for commit e773f85. ± Comparison against base commit 4762446. This pull request removes 10 and adds 10 tests. Note that renamed tests count towards both.FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetLengthExceptionMessage'.) Object name: 'GetPositionExceptionMessage'.) FluentAssertions.Specs.Primitives.StringAssertionSpecs+Be ‑ When_long_string_contains_braces_it_should_display_properly FluentAssertions.Specs.Primitives.StringAssertionSpecs+Be ‑ When_string_contains_opening_brace_it_should_not_throw_format_exception FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetLengthExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetLengthExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetPositionExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetPositionExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetLengthExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetLengthExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetPositionExceptionMessage'.) FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'GetPositionExceptionMessage'.) ♻️ This comment has been updated with latest results. |
Sorry, something went wrong.
Pull Request Test Coverage Report for Build 21300676482Details
💛 - Coveralls |
Sorry, something went wrong.
Qodana for .NETIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact us at qodana-support@jetbrains.com
|
Sorry, something went wrong.
Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
|
|
||
| if (IncludeFullDetails && wasTruncated) | ||
| { | ||
| sb.AppendFormat(CultureInfo.InvariantCulture, |
There was a problem hiding this comment.
If we polyfill StringBuilder.Append in StringBuilderExtensions we can avoid the intermediate string.
sb.Append(CultureInfo.InvariantCulture,
$"""
Full expectation:
{expected.RenderAsIndentedBlock()},
Full subject:
{subject.RenderAsIndentedBlock()}
""");For StringBuilderExtensions
public static StringBuilder AppendLine(this StringBuilder stringBuilder, IFormatProvider provider, FormattableString formattable) =>
stringBuilder.AppendLine(string.Create(provider, formattable));
public static StringBuilder Append(this StringBuilder stringBuilder, IFormatProvider provider, FormattableString formattable) =>
stringBuilder.Append(string.Create(provider, formattable));
Sorry, something went wrong.
There was a problem hiding this comment.
Is that a suggestion? And why is that important? This code is only executed for a failing test and when the full details are requested.
Sorry, something went wrong.
There was a problem hiding this comment.
It's a suggestion and not blocking for approving the PR.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Be() assertion throws FormatException instead of test failure when comparing strings containing { or } characters.
Root Cause
StringEqualityStrategy.GetMismatchSegmentForLongStrings used StringBuilder.AppendFormat with an interpolated string literal containing user values:
This causes double-interpretation: string interpolation inserts user values first, then AppendFormat interprets the result as a format string. Braces in user strings are mistaken for format placeholders.
Changes
This ensures user strings are never reinterpreted as format strings.
Original promptThis section details on the original issue you should resolve
<issue_title>Be() throws System.FormatException when expected value contains "{"</issue_title>
<issue_description>### Description
Hi,
I was writing tests for my code formatter and came across this weird behavior - FluentAssertions use string.Format without sanitizing the values (but that is not optimal solution IMHO).
It is kind of annoying:
This works just fine:
This throws throws System.FormatException.
Thanks
Reproduction Steps
P.S.: The fact that it fails around 79-80 is funny.
Expected behavior
Be should throw only XunitException for string comparisons - strings are either equal or not equal.
IMHO, building final assertion message incrementally using multiple string.Format calls feels too hacky.
Probably, a better approach would be to create some tree-ish type and walking over it to build the final string. But I'm not regularly programming in C# so don't listen to me. :)
Actual behavior
In reproduction tests:
Full dotnet test result: