Test: Expand SystemSettingsService test coverage to all catalog settings#93
Conversation
There was a problem hiding this comment.
Pull request overview
Expands SystemSettingsService unit test coverage to validate more catalog setting → registry tweak mappings and captured-setting translations, improving confidence in both generation and capture logic for Windows system tweaks.
Changes:
- Added tests for the
strictsecurity preset and additional catalog settings (e.g., dark mode, taskbar alignment/widgets, file visibility, seconds-in-clock, explorer launch target, Bing search). - Added edge-case tests for
GetTweaksAsync(null/empty settings, unknown keys, invalid values). - Added
GetFriendlyNamemapping tests (known tweaks and unknown paths).
Comments suppressed due to low confidence (1)
tests/WinHome.Tests/SystemSettingsServiceTests.cs:163
- There’s a lot of repeated Arrange/Act/Assert structure across the new GetTweaksAsync tests (true/false or left/center variants). Converting these to [Theory] tests with InlineData (and possibly a small helper to assert a single expected tweak) would reduce duplication and make it easier to add new catalog settings/options later.
[Fact]
public async Task GetTweaksAsync_Should_Return_TaskbarAlignment_Tweaks()
{
var settingsLeft = new Dictionary<string, object> { { "taskbar_alignment", "left" } };
var tweaksLeft = await _service.GetTweaksAsync(settingsLeft);
var listLeft = new List<RegistryTweak>(tweaksLeft);
Assert.Single(listLeft);
Assert.Equal("TaskbarAl", listLeft[0].Name);
Assert.Equal(0, listLeft[0].Value);
var settingsCenter = new Dictionary<string, object> { { "taskbar_alignment", "center" } };
var tweaksCenter = await _service.GetTweaksAsync(settingsCenter);
var listCenter = new List<RegistryTweak>(tweaksCenter);
Assert.Single(listCenter);
Assert.Equal("TaskbarAl", listCenter[0].Name);
Assert.Equal(1, listCenter[0].Value);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [Fact] | ||
| public async Task GetTweaksAsync_Should_Return_DarkMode_Tweaks() | ||
| { | ||
| var settingsTrue = new Dictionary<string, object> { { "dark_mode", "true" } }; | ||
| var tweaksTrue = await _service.GetTweaksAsync(settingsTrue); | ||
| var tweaksListTrue = new List<RegistryTweak>(tweaksTrue); | ||
|
|
||
| Assert.Equal(2, tweaksListTrue.Count); | ||
| Assert.Contains(tweaksListTrue, t => t.Name == "AppsUseLightTheme" && t.Value.Equals(0)); | ||
| Assert.Contains(tweaksListTrue, t => t.Name == "SystemUsesLightTheme" && t.Value.Equals(0)); | ||
|
|
||
| var settingsFalse = new Dictionary<string, object> { { "dark_mode", "false" } }; | ||
| var tweaksFalse = await _service.GetTweaksAsync(settingsFalse); | ||
| var tweaksListFalse = new List<RegistryTweak>(tweaksFalse); | ||
|
|
||
| Assert.Equal(2, tweaksListFalse.Count); | ||
| Assert.Contains(tweaksListFalse, t => t.Name == "AppsUseLightTheme" && t.Value.Equals(1)); | ||
| Assert.Contains(tweaksListFalse, t => t.Name == "SystemUsesLightTheme" && t.Value.Equals(1)); | ||
| } |
| .Setup(r => r.Read(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme")) | ||
| .Returns(0); | ||
| _mockRegistryService | ||
| .Setup(r => r.Read(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme")) | ||
| .Returns(0); | ||
|
|
||
| var capturedTrue = await _service.GetCapturedSettingsAsync(); | ||
| Assert.True(capturedTrue.ContainsKey("dark_mode")); | ||
| Assert.True((bool)capturedTrue["dark_mode"]); | ||
|
|
||
| _mockRegistryService.Invocations.Clear(); | ||
| _mockRegistryService | ||
| .Setup(r => r.Read(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme")) | ||
| .Returns(1); | ||
| _mockRegistryService | ||
| .Setup(r => r.Read(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme")) | ||
| .Returns(1); | ||
|
|
|
@omnipotentchaos resolve the github copilot suggestions, I also need the screenshot of the working code |
DotDev262
left a comment
There was a problem hiding this comment.
Review
Solid work on expanding test coverage. The tests are clean and follow existing patterns well. A few improvements requested:
Should fix (non-blocking but good practice):
- Multiple assertions per [Fact] — several tests bundle true/false cases in one method (e.g., GetTweaksAsync_Should_Return_DarkMode_Tweaks, GetCapturedSettingsAsync_Should_Capture_DarkMode, and all the similar true/false patterns). Please refactor these into [Theory] [InlineData] tests so each case runs independently and failure of one doesn't hide the other.
- Code duplication — the same Arrange/Act/Assert pattern is repeated ~16 times across settings (dark_mode, taskbar_alignment, taskbar_widgets, show_file_extensions, show_hidden_files, seconds_in_clock, bing_search_enabled, explorer_launch_to). Converting to [Theory] with [InlineData] and a helper method would reduce this by ~60%.
- null! null-forgiving operator in GetTweaksAsync_Should_Return_Empty_On_Null_Settings — if GetTweaksAsync should accept null, consider making the parameter explicitly nullable (Dictionary<string, object>?) rather than suppressing the warning with !.
Note:
- The 3 failed tests (symlink, uv, bun) are environment-specific and expected on non-Windows — no action needed.
- PR #63 recently added a privacy security preset — consider adding tests for it in a follow-up.
Overall these are incremental improvements, not blockers. The tests are functional and comprehensive.
|
Hi @DotDev262, thank you for the helpful feedback! I have successfully addressed all suggestions in the latest commits:
All 160+ cross-platform unit tests compile perfectly and pass successfully! |
ReviewThanks for the contribution. A few things to fix before this can be merged: Must fix
Note
The test coverage improvements are otherwise solid — the |
b94686e to
c044753
Compare
|
@DotDev262 I have completed all the requested fixes. |




Test: Expand SystemSettingsService test coverage to all catalog settings
Related Issue
Closes #75
Proposed Changes
SystemSettingsServiceTests.csto achieve full test coverage for all 12 remaining catalog settings (for bothGetTweaksAsyncandGetCapturedSettingsAsyncwith all valid options).strictsecurity preset (baseline tweaks plus three strict registry settings).GetFriendlyName(known settings and unknown paths).dotnet format.CS8625in tests using a null-forgiving operator.Type of Change
Screenshots / Logs (if applicable)
Testing & Verification
dotnet testand all 60+ cross-platform tests passed.GSSOC 2026 Checklist
dotnet format).gssoc:approvedlabel for this PR to count for points.