Skip to content

Fix MonthCalendar test failures across midnight - #15404

Merged
Shyam-Gupta merged 2 commits into
mainfrom
dev/shgu/mctests
Nov 12, 2026
Merged

Shyam-Gupta merged 2 commits into
mainfrom
dev/shgu/mctests

Conversation

@Shyam-Gupta

@Shyam-Gupta Shyam-Gupta commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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.Date during 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

Shyam-Gupta and others added 2 commits November 11, 2026 11:09
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
@Shyam-Gupta Shyam-Gupta self-assigned this Nov 11, 2026
@Shyam-Gupta
Shyam-Gupta requested a review from a team as a code owner November 11, 2026 19:37
@Shyam-Gupta Shyam-Gupta added the test-bug Problem in test source code (most likely) label Nov 11, 2026
@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.79260%. Comparing base (8a95231) to head (1de1a4f).
⚠️ Report is 3 commits behind head on main.

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           
Flag Coverage Δ
Debug 39.79260% <ø> (ø)
production 42.31695% <ø> (ø)
test 19.92786% <ø> (ø)
unit 42.31695% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Shyam-Gupta
Shyam-Gupta merged commit 6ee76da into main Nov 12, 2026
10 checks passed
@Shyam-Gupta
Shyam-Gupta deleted the dev/shgu/mctests branch November 12, 2026 07:48
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-bug Problem in test source code (most likely)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants