| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This PR improves BeEquivalentTo failure diagnostics for collection equivalency by including the original index of extraneous (subject-only) items in the assertion failure message (Fixes #985), making it easier to locate where collections diverge.
Changes:
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| docs/_pages/releases.md | Adds a release note describing the improved BeEquivalentTo extraneous-item messaging. |
| Tests/FluentAssertions.Specs/Collections/CollectionAssertionSpecs.BeEquivalentTo.cs | Updates an existing assertion message expectation to match the new output shape. |
| Tests/FluentAssertions.Equivalency.Specs/CollectionSpecs.cs | Updates single-extra-item expectation and adds coverage for multiple extra items including indices. |
| Tests/FluentAssertions.Equivalency.Specs/BasicSpecs.cs | Updates golden failure-message text to include the extraneous item index. |
| Src/FluentAssertions/Equivalency/Steps/StrictlyOrderedEquivalencyStrategy.cs | Changes subject inputs to IndexedItem<object> and compares using .Item. |
| Src/FluentAssertions/Equivalency/Steps/LooselyOrderedEquivalencyStrategy.cs | Changes subject inputs to IndexedItem<object> and compares using .Item throughout matching/scoring. |
| Src/FluentAssertions/Equivalency/Steps/EnumerableEquivalencyValidator.cs | Wraps subjects with original indices and updates failure reporting to include indices for extraneous-only cases. |
Sorry, something went wrong.
Test Results 37 files ± 0 37 suites ±0 2m 47s ⏱️ -1s Results for commit 6059560. ± Comparison against base commit fb42954. 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.Equivalency.Specs.CollectionSpecs ‑ When_the_subject_contains_multiple_extra_items_it_should_include_the_index_of_each FluentAssertions.Equivalency.Specs.CollectionSpecs ‑ When_the_subject_contains_multiple_extra_items_the_failure_message_should_include_their_formatted_properties 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.
Coverage Report for CI Build 25427286962Coverage decreased (-0.002%) to 97.14%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - 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.
There was a problem hiding this comment.
Nice!
Sorry, something went wrong.
When BeEquivalentTo fails because the subject collection has more items
than expected, the error message now includes the original index of each
extraneous item to help diagnose where collections diverge.
Before:
found one extraneous item Customer { Age = 16, ... }
After:
found one extraneous item at index 1 Customer { Age = 16, ... }
For multiple extra items:
found extraneous items {Customer { Age = 16, ... } (at index 1), ...}
Fixes #985
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Escape { and } in Formatter.ToString output before embedding into
the FailWith format string, preventing string.Format from treating
object dumps like 'Customer { Age = 16 }' as format placeholders
- Pass a single item (not a 1-element list) as the {1} argument
whenever remainingSubjects.Count == 1, matching the previous
behavior for the 'both missing and extra' fallback path
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Multi-item: 'found extraneous items: A (at index 3), B (at index 96)'
instead of 'found extraneous items {A (at index 3), B (at index 96)}'
- Single-item: 'found one extraneous item at index 1: X'
instead of 'found one extraneous item at index 1 X'
- Fix TestBeEquivalent to be a proper test with a throw assertion
and a descriptive name
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lidator.cs Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
Without escaping curly braces in the formatted items string, string.Format throws a FormatException, causing a **WARNING** fallback instead of the actual failure message. The existing test didn't catch this because the WARNING still contained the expected text from the raw format string. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
…lidator.cs Co-authored-by: Jonas Nyrup <jnyrup@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #985.
When BeEquivalentTo fails because the subject collection has more items than expected, the error message now includes the original index of each extraneous item, making it easier to diagnose where collections diverge.
Before
Expected actual to contain exactly one item, but found one extraneous item Customer { Age = 16, ... }After
Single extra item:
Expected actual to contain exactly one item, but found one extraneous item at index 1: Customer { Age = 16, ... }Multiple extra items:
Expected actual to contain exactly 2 items, but found extraneous items: Customer { Age = 16, ... } (at index 2), Customer { Age = 21, ... } (at index 4)Implementation