Skip to content

Comparing DateOnly with DateTime using BeEquivalentTo shows a non-useful error #3048

@robvanuden

Description

@robvanuden

Description

Comparing a DateOnly with a DateTime with BeEquivalentTo creates a message where the 2 values are the same, like:

Expected property SomeDate to be <2020-01-02>, but found <2020-01-02>.

Reproduction Steps

new { SomeDate = new DateOnly(2020, 1, 2) }.Should().BeEquivalentTo(new { SomeDate = new DateTime(2020, 1, 2) });

Expected behavior

It should make clear that the error is in the typing, not in the values. Maybe by always showing the time for a DateTime object?

Actual behavior

Error message:
Expected property SomeDate to be <2020-01-02>, but found <2020-01-02>.

Regression?

No response

Known Workarounds

No response

Configuration

FluentAssertions 8.0.2, .NET 8

Other information

No response

Are you willing to help with a pull-request?

No

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions