Repository navigation
Fix MonthCalendar test failures across midnight - #15404
Merged
Merged
Conversation
MonthCalendarTests computed DateTime.Now.Date in MemberData, which xUnit evaluates at discovery time, while each MonthCalendar captures its own "today" (default selection) at construction. When a test run straddled midnight (as in CI build 1671901, agents in UTC), expected values were a day behind the control state, and SetSelectionRange's MaxSelectionCount clamp took a different branch. Derive today-relative expectations from the calendar's initial SelectionStart inside the test body instead: - MinDate/MaxDate: null expected selection means the initial selection. - SelectionStart/SelectionEnd/SelectionRange/SetSelectionRange: move today-relative rows to InlineData theories using day/hour offsets. Fixed-date rows and overall coverage are unchanged. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5e110331-0d67-4628-85a6-5c83fb1ba599
Add a purpose comment to each relative-to-today test, noting the selection behavior covered and whether the native handle is created. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5e110331-0d67-4628-85a6-5c83fb1ba599
yaqiyang
approved these changes
Nov 11, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15404 +/- ##
=============================================
Coverage 39.79260% 39.79260%
=============================================
Files 246 246
Lines 9836 9836
Branches 1036 1036
=============================================
Hits 3914 3914
Misses 5741 5741
Partials 181 181
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Fixes test failures in build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1671901&view=ms.vss-test-web.build-test-results-tab
Prevents flaky date assertions by deriving test dates from each calendar’s initial selection. Adds coverage for selection behavior with and without a native handle.
Root cause: Theory data captured
DateTime.Now.Dateduring discovery, but each calendar initialized its selection later. When the run crossed midnight, the dates differed, causing incorrect expectations and a different selection-range clamping path.Fix: Derive relative dates from each calendar’s initial SelectionStart inside the test. This covers min/max date and selection tests, with and without a native handle.
Microsoft Reviewers: Open in CodeFlow