-
Notifications
You must be signed in to change notification settings - Fork 733
Clarify the date/time type when comparing dates, times and combinations of those #3049
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
Clarify the date/time type when comparing dates, times and combinations of those #3049
Conversation
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 Qodana teamContact us at [email protected]
|
3fbf612
to
7b85fec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
DateAndTimeEquivalencyStep
to 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Src/FluentAssertions/Equivalency/Steps/DateAndTimeEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Equivalency/Steps/DateAndTimeEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
eb592a0
to
cddcb6a
Compare
Introduces a new
DateAndTimeEquivalencyStep
forBeEquivalentTo
that 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 spellcheck
or.\build.ps1 --target spellcheck
before pushing and check the good outcome