Skip to content

Conversation

@facundo91
Copy link
Contributor

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

Fixes #1427

To mimic the behavior of NumericAssertions, I have added the cases marked in bold to DateTimeAssertions and DateTimeOffsetAssertions. Below examples are for Datetime, but same logic was followed for DatetimeOffset.

subject.Be(expected)

subject expected result
16/11/2020 16/11/2020 true
16/11/2020 null false
null 16/11/2020 false
null null true

subject.NotBe(expected)

subject expected result
16/11/2020 16/11/2020 false
16/11/2020 null true
null 16/11/2020 true
null null false

IMPORTANT

  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by a new or existing set of unit tests which follow the Arrange-Act-Assert syntax such as is used in this example.
  • If the contribution adds a feature or fixes a bug, please update the release notes, which are published on the website.
  • If the contribution changes the public API the changes needs to be included by running AcceptApiChanges.ps1/AcceptApiChanges.sh.
  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.

Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR. Just some nitpicking/suggestions if you're up to it.

@facundo91
Copy link
Contributor Author

Thank you for the suggestions @dennisdoomen , it is now ready to be merge.

Copy link
Member

@jnyrup jnyrup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not crucial, but would be nice with tests exercising subject, expected or both being null.

@dennisdoomen dennisdoomen requested a review from jnyrup November 17, 2020 14:15
@dennisdoomen dennisdoomen merged commit 17e53fa into fluentassertions:develop Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants