{{ message }}
Add HaveMillisecond/NotHaveMillisecond assertion methods for DateTime and DateTimeOffset#3164
Merged
Merged
Conversation
Co-authored-by: jnyrup <919634+jnyrup@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add method to assert millisecond part of DateTimeOffset
Add HaveMillisecond/NotHaveMillisecond assertion methods for DateTime and DateTimeOffset
Feb 28, 2026
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 qodana-support@jetbrains.com
|
jnyrup
requested changes
Mar 4, 2026
Member
There was a problem hiding this comment.
@copilot please address the following points:
- Update
docs/_pages/releases.mdto include a sub-item under "What's New" succiently summarizing the feature added in this PR - Run either of
AcceptApiChanges.shorAcceptApiChanges.ps1to updates the approved API. - Update the naming of the added test methods to the folllow the new naming convention.
- See e.g. Tests/FluentAssertions.Specs/Numeric/NumericAssertionSpecs.BeNaN.cs
Member
@copilot apply the requested changes |
…nges Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
Contributor
Author
All requested changes have been applied in commit fcb2dfc:
All tests pass: 18 HaveMillisecond tests, 4 approval tests, and no regressions in existing DateTime/DateTimeOffset tests. |
Pull Request Test Coverage Report for Build 22803252634Details
💛 - Coveralls |
jnyrup
reviewed
Mar 5, 2026
Co-authored-by: dennisdoomen <572734+dennisdoomen@users.noreply.github.com>
jnyrup
approved these changes
Mar 7, 2026
dennisdoomen
approved these changes
Mar 8, 2026
This was referenced Mar 16, 2026
This was referenced Jun 29, 2026
Open
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Implementation Complete ✓
HaveMillisecondandNotHaveMillisecondmethods to DateTimeAssertions classHaveMillisecondandNotHaveMillisecondmethods to DateTimeOffsetAssertions classdocs/_pages/releases.mdwith feature summaryAcceptApiChanges.shto update approved APISummary
Successfully implemented
HaveMillisecondandNotHaveMillisecondassertion methods for bothDateTimeandDateTimeOffsettypes, following the existing patterns. All tests pass successfully with no regressions detected. Test naming has been refined to follow clean naming conventions without rigid and noisy words.Original prompt
This section details on the original issue you should resolve
<issue_title>Method to assert the millisecond part of a DateTime / DateTimeOffset instance</issue_title>
<issue_description>### Background and motivation
Currently, FluentAssertions has methods to assert the year, month, day, hour, minute, second and offset of a DateTimeOffset (HaveX), but an equivalent method for the millisecond part is missing. Generally, it would be nice to assert the millisecond part in the style of FluentAssertions instead of using
result.Millisecond.Should().Be(milliseconds).I'm currently working on a library that provides convenience methods based on DateTime/DateTimeOffset and implement date and time related unit tests for it.
This is very easy to implement, because we can extend the DateTimeAssertions class and DateTimeOffsetAssertions class by a method called
HaveMillisecond.The implementation of this method could look like following:
Also the opponent of
HaveMillisecond, which would beNotHaveMillisecond, can be implemented this way by inverting / changing the condition tothis.Subject!.Value.Millisecond != expectedMilliseconds.API Proposal
API Usage
Alternative Designs
Alternately, you could write an extension method based on
DateTimeOffsetAssertionsclass and add there theHaveMillisecondmethod. This would not directly change the API of FluentAssertions, but would not be consistent with the rest of the DateTime/DateTimeOffset method provided by FluentAssertions.The extension method could be implemented like following:
Risks
None, because it adds an extra method to assert the millisecond part of a DateTime / DateTimeOffset instance.
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
Yes, please assign this issue to me.</issue_description>
Comments on the Issue (you are @copilot ...
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.