Repository navigation
test: add xUnit test project with 100% coverage gate - #42
Merged
Merged
Conversation
Move the link workflow out of MainWindow into testable classes (LinkCreator, Mklink, UiHelpers) behind a small dialog interface, and cover them with tests against the real file system. - dotnet test runs on Microsoft.Testing.Platform (global.json) and fails below 100% line, branch or method coverage (coverlet.MTP) - WPF and UAC glue is marked [ExcludeFromCodeCoverage] - CI runs the tests on pull requests and uploads the coverage report - Remove unreachable branches in the move and rollback paths - Update CLAUDE.md for the WPF layout and testing Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-coverage-3c8c43 # Conflicts: # CLAUDE.md # Symlinker/MainWindow.xaml.cs # Symlinker/Program.cs
…-coverage-3c8c43 # Conflicts: # CLAUDE.md # Symlinker/Elevation.cs # Symlinker/MainWindow.Inputs.cs # Symlinker/MainWindow.xaml.cs
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.
Summary
Adds a
Symlinker.Testsproject (xUnit v3) and a coverage gate: everydotnet testrun collects coverage for the app and fails below 100% line, branch or method coverage. CI now runs the tests on pull requests and uploads the Cobertura report.To make the app testable, the logic moves out of the window into plain classes.
MainWindowis now view glue. This branch is up to date with #40 (UI/UX fixes) and #41 (elevate only the link step), and both are wired through the new classes without changing their behavior.What changed
New classes (all tested)
LinkCreator: the link workflow (replace prompts, move-and-link, copy with progress across drives, rollback on failure). It talks to anIDialogServiceand anILinkRunner, so tests drive it with fakes against the real file system.LinkRunner(ILinkRunner): feat: elevate only the link step instead of restarting as admin #41's "elevate only when needed" logic, moved out of the window.PrepareAsync()starts the admin helper (one UAC prompt) before anything on disk changes, restarts it if it died, and returns false on a declined prompt.RunAsync()sends symbolic links that need admin to the helper and everything else toLinkCommand.InputValidator: the field checks behind fix: address main window UI/UX review findings #40's inline errors, plusColorContrastfor text on the accent color.UiHelpers: path names, picker start folders, byte formatting, app version,LinkNameAutoFill.Dialogs.cs:IDialogService/IProgressDialogand the MahApps implementation.Changes to code from #40 and #41
LinkCommand(feat: elevate only the link step instead of restarting as admin #41) now also holds theLinkKindenum andLinkKindsname mapping, and itsBuildArgumentssafety checks are tested case by case. My earlierMklink.csis gone: feat: elevate only the link step instead of restarting as admin #41's stricter version replaces it.ElevatedLinker(feat: elevate only the link step instead of restarting as admin #41) implementsILinkHelper. Its pipe protocol is tested in-process: the test holds the window's end of the pipe and runsRunHelperon a background thread, creating real junctions. That covers bad arguments, the wrong parent process, connect timeout, unreadable requests, and the helper hanging up.Elevation.CanCreateSymbolicLinksgets an overload with the link creation passed in, so every probe outcome is tested.LaunchOptionsgetsIsFolderModeandKind, which the window uses to apply options.LinkInput, so it doesn't clash with feat: elevate only the link step instead of restarting as admin #41'sLinkRequest.Excluded from coverage (
[ExcludeFromCodeCoverage], each with a justification)MainWindow,App,Program,MetroDialogService,InputError: need a live window.ElevatedLinker.StartAsync: shows the UAC prompt.ElevatedLinker.GetServerProcessId,Elevation.GetShieldIcon: native calls whose failure paths can't be triggered.Tooling
global.jsonoptsdotnet testinto Microsoft.Testing.Platform (xunit.v3 4.x requires it on the .NET 10 SDK).coverlet.MTP. The settings are inSymlinker.Tests.csproj.CLAUDE.mddocuments the testing setup and the new classes.Behavior changes (small, from removing unreachable branches)
Path.Combine(target, ".."). Before, a target typed with a trailing slash (D:\x\y\) createdyitself, and the move then failed.LinkMover.IsLinkdrops a redundantExistscheck. Missing entries are still "not a link".LinkPathInUsedrops acatch (ArgumentException)thatPath.Combinecan no longer throw on .NET Core.LinkCreator, the window asked before the delete and checked again before mklink; the second check was always a no-op.Reviewer notes
Symlinker.exe --link-helperwith bad arguments exits with code 2, and the window launches with--mode file --type hard.LinkRunnerTestsandLinkCreatorTests.🤖 Generated with Claude Code