Skip to content

Conversation

@jnyrup
Copy link
Member

@jnyrup jnyrup commented Apr 2, 2020

This PR makes most assertions generic in TAssertions.
This benefits deriving from one of those assertion classes, as chaining
with .And allows you to continue use assertions from the derived class instead
of only from the base class.

Utilizing the generic type system this way also caught wrong return types.
NullableDateTimeAssertions.Be returned an DateTimeAssertions,
where it could return an NullableDateTimeAssertions.
Similar "bugs" were also caught in NullableDateTimeOffsetAssertions and
NullableBooleanAssertions.

Child classes are included to match the current signatures, which is
seen by noticing that all return types of Shoulds remain the same.

The only types that do not have child classes are

  • AndWhichConstraint
  • DateTimeRangeAssertions
  • DateTimeOffsetRangeAssertions

This PR also serves as a preparation for an upcoming PRs that will improve dictionary assertions.

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.

Great improvement man

This PR makes most assertions generic in `TAssertions`.
This benefits deriving from one those assertion classes, as chaining
with `.And` allows you to continue use assertions from the derived class instead
of only from the base class.

Utilizing the generic type system this way also caught wrong return types.
`NullableDateTimeAssertions.Be` returned an
`DateTimeAssertions`, where it could return an
`NullableDateTimeAssertions`.
Similar "bugs" were caught in `NullableDateTimeOffsetAssertions` and
`NullableBooleanAssertions`.

Child classes are included to match the current signatures, which is
seen by noticing that all return types of `Should`s remain the same.
The only types that do not have child classes are
* `AndWhichConstraint`
* `DateTimeRangeAssertions`
* `DateTimeOffsetRangeAssertions`

This PR also served as a preparation for upcoming PRs that will improve
delegate and dictionary assertions
@jnyrup jnyrup merged commit fdce702 into fluentassertions:develop Apr 3, 2020
@jnyrup jnyrup deleted the TAssertions branch April 3, 2020 06:46
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.

2 participants