Skip to content

Add DateTime.Should().Be(DateTime?) and DateTimeOffset.Should().Be(DateTimeOffset?) overloads #1427

@julealgon

Description

@julealgon

Description

Some overloads of Be for primitive types have a nullable version to facilitate calling them against standard and nullable versions of the value. For example:

Normal:
image

Nullable:
image

However, these nullable overloads do not exist currently for both DateTime and DateTimeOffset.

I propose the overloads be added to help with testing these types of properties and for consistency in the FluentAssertions API.

Expected behavior:

2 overloads be added, one for DateTime and another for DateTimeOffset, allowing to compare (Be) with their nullable counterparts. When the values are null, the assertion should obviously fail.

Actual behavior:

Overloads do not exist, forcing extra logic inside assertions to get the .Value.

Versions

  • FluentAssertions 5.10.3
  • Net Core 3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions