{{ message }}
Clarify the date/time type when comparing dates, times and combinations of those#3049
Merged
dennisdoomen merged 1 commit intoMay 25, 2025
Merged
Conversation
3fbf612 to
7b85fec
Compare
There was a problem hiding this comment.
Pull Request Overview
Adds a new equivalency step to include explicit type information when comparing date/time values of different types, along with tests and API approvals.
- Introduce
DateAndTimeEquivalencyStepto fail with type details when subject and expectation are both date/time types but not the same type - Register the new step in the default equivalency plan (
EquivalencyPlan) - Add missing tests covering DateOnly, TimeOnly, TimeSpan, DateTimeOffset comparisons
- Update API approval snapshots to include the new public step
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Src/FluentAssertions/Equivalency/Steps/DateAndTimeEquivalencyStep.cs | New step implementation comparing mismatched date/time types |
| Src/FluentAssertions/Equivalency/EquivalencyPlan.cs | Register DateAndTimeEquivalencyStep in the default steps sequence |
| Tests/FluentAssertions.Equivalency.Specs/DateTimePropertiesSpecs.cs | Add tests to verify failure messages include type information for all date/time combinations |
| Tests/Approval.Tests/ApprovedApi/FluentAssertions/net*.verified.txt | Update API approval files to include the new DateAndTimeEquivalencyStep |
Comments suppressed due to low confidence (2)
Src/FluentAssertions/Equivalency/Steps/DateAndTimeEquivalencyStep.cs:13
- [nitpick] Override ToString() for this class to give a descriptive name when listing or debugging equivalency steps, matching the pattern used by other steps.
public class DateAndTimeEquivalencyStep : IEquivalencyStep
Src/FluentAssertions/Equivalency/EquivalencyPlan.cs:155
- Align the indentation of this line with the surrounding step registrations to maintain consistent formatting.
new DateAndTimeEquivalencyStep(),
7b85fec to
eb592a0
Compare
Pull Request Test Coverage Report for Build 15236385907Details
💛 - Coveralls |
jnyrup
requested changes
May 25, 2025
jnyrup
left a comment
Member
There was a problem hiding this comment.
I'm fine with this as it improves clarity of the failure message.
I had preferred if we just changed DateTimeOffsetValueFormatter to not skip rendering the time of day at midnight.
jnyrup
reviewed
May 25, 2025
eb592a0 to
cddcb6a
Compare
jnyrup
approved these changes
May 25, 2025
This was referenced Jul 21, 2025
This was referenced Jun 16, 2026
Merged
This was referenced Jun 24, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Introduces a new
DateAndTimeEquivalencyStepforBeEquivalentTothat will include the type of the comparands in the failure message if the subject and expectation aren't of the same date/time type like this:Expected property subject.SomeDate to be <2020-01-02> (of type System.DateTime), but found <2020-01-02> (of type System.DateOnly#3048
IMPORTANT
./build.sh --target spellcheckor.\build.ps1 --target spellcheckbefore pushing and check the good outcome