Problem
Sixteen test cases that exist to pin admin-gated behaviour assert nothing where they run, because each one opens by skipping itself on an elevated host — and the CI runner is elevated. The repo already knows this: EtwBandwidthSourceTests.cs:213 carries the comment // elevated CI runner: the negative path is moot.
Six guard sites:
| File |
Cases |
SysManager.Tests/CleanupViewModelTests.cs:205,218 |
2 — SFC and DISM refuse without admin |
SysManager.Tests/EtwBandwidthSourceTests.cs:213 |
1 |
SysManager.IntegrationTests/WindowsUpdateViewModelTests.cs:96,108 |
2 (project is never executed at all, see #2101) |
SysManager.UITests/AdminBannerUiTests.cs:45 |
9 — the whole privileged-tab banner net, in a warning-only job |
The main workstation cannot run dotnet test, so no environment in the project executes the branch these tests were written for. The elevation gate on SFC, DISM, Windows Update and the nine privileged tabs is effectively unpinned.
CleanupViewModel makes it worse by asking twice: line 77 seeds an IsElevated property from AdminHelper.IsElevated(), while the command guards at 309 and 416 call the static again. A test cannot influence either.
Separately: an integration test with no assertion
SysManager.IntegrationTests/InfrastructureTests.cs:144 — WingetService_EventForwardingWorks subscribes to LineReceived, fetches a FieldInfo and discards it, then discards the flag with _ = gotLine;. It constructs a real PowerShellRunner, asserts nothing, and always passes. Its own comments admit it: "We accept that this path requires a running session; skip if not possible."
Expected behavior
Elevation is a dependency, not an ambient fact, so a test can state it. Route AdminHelper.IsElevated() through a seam the way TimeProvider handles the clock — one injectable/overridable source, consumed everywhere including the command guards — and the negative path becomes deterministic on any host, elevated or not. Then the skip guards come out and the assertions run everywhere.
WingetService_EventForwardingWorks either asserts that a line raised on the runner reaches the service's subscribers, or it is deleted. A test that cannot fail is worse than no test: it reports coverage it does not have.
Evidence
Guard sites from grep -rn 'IsElevated()' --include=*.cs across all three test projects, excluding obj/.
Affected area
Test suite (Cleanup, Windows Update, Bandwidth Monitor, the 9 privileged tabs)
Problem
Sixteen test cases that exist to pin admin-gated behaviour assert nothing where they run, because each one opens by skipping itself on an elevated host — and the CI runner is elevated. The repo already knows this:
EtwBandwidthSourceTests.cs:213carries the comment// elevated CI runner: the negative path is moot.Six guard sites:
SysManager.Tests/CleanupViewModelTests.cs:205,218SysManager.Tests/EtwBandwidthSourceTests.cs:213SysManager.IntegrationTests/WindowsUpdateViewModelTests.cs:96,108SysManager.UITests/AdminBannerUiTests.cs:45The main workstation cannot run
dotnet test, so no environment in the project executes the branch these tests were written for. The elevation gate on SFC, DISM, Windows Update and the nine privileged tabs is effectively unpinned.CleanupViewModelmakes it worse by asking twice: line 77 seeds anIsElevatedproperty fromAdminHelper.IsElevated(), while the command guards at 309 and 416 call the static again. A test cannot influence either.Separately: an integration test with no assertion
SysManager.IntegrationTests/InfrastructureTests.cs:144—WingetService_EventForwardingWorkssubscribes toLineReceived, fetches aFieldInfoand discards it, then discards the flag with_ = gotLine;. It constructs a realPowerShellRunner, asserts nothing, and always passes. Its own comments admit it: "We accept that this path requires a running session; skip if not possible."Expected behavior
Elevation is a dependency, not an ambient fact, so a test can state it. Route
AdminHelper.IsElevated()through a seam the wayTimeProviderhandles the clock — one injectable/overridable source, consumed everywhere including the command guards — and the negative path becomes deterministic on any host, elevated or not. Then the skip guards come out and the assertions run everywhere.WingetService_EventForwardingWorkseither asserts that a line raised on the runner reaches the service's subscribers, or it is deleted. A test that cannot fail is worse than no test: it reports coverage it does not have.Evidence
Guard sites from
grep -rn 'IsElevated()' --include=*.csacross all three test projects, excludingobj/.Affected area
Test suite (Cleanup, Windows Update, Bandwidth Monitor, the 9 privileged tabs)