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.
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
left a comment
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.
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
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