Skip to content

Add unit tests for core utility and Syncthing components#213

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/add-unit-tests
Draft

Add unit tests for core utility and Syncthing components#213
Copilot wants to merge 1 commit intomainfrom
copilot/add-unit-tests

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 26, 2026

The codebase had virtually no unit tests. This PR adds focused, non-overfit coverage for the most testable pure-logic components.

New test classes

  • StringExtensionsTestsTrimStart, TrimMatchingQuotes, SplitCommandLine (quoted args, extra spaces, empty input), JoinCommandLine (space-quoting, embedded quote escaping), and a split↔join round-trip
  • FormatUtilsTestsBytesToHuman across B/KiB/MiB/GiB unit boundaries with varying decimalPlaces; asserts bytes never show decimal places and GiB is the ceiling unit
  • ChecksumFileUtilitiesTests — write produces a valid checksum line; validate returns true/false for matching/modified content; multi-entry file lookup; missing filename throws; full write→validate round-trip via MemoryStream
  • UriExtensionsTestsNormalizeZeroHost rewrites 0.0.0.0 → 127.0.0.1 preserving port and path; leaves all other hosts untouched
  • SyncthingVersionInformationTests — version regex extraction from v1.23.4, longer strings like syncthing v1.2.3, and fallback to 0.0.0 for empty/non-matching input
  • SyncthingCapabilitiesTestsSupportsDebugFacilities / SupportsDevicePauseResume flags correct below, at, and above the introduced-version threshold; default instance (0.0.0) has no capabilities

All tests use xunit (already in the test project) and operate entirely in-memory — no UI, disk, or network dependencies.

- StringExtensionsTests: TrimStart, TrimMatchingQuotes, SplitCommandLine,
  JoinCommandLine, and a round-trip split/join test
- FormatUtilsTests: BytesToHuman across byte/KiB/MiB/GiB boundaries with
  varying decimal places
- ChecksumFileUtilitiesTests: write/validate round-trip, multi-entry lookup,
  modified-content returns false, missing filename throws
- UriExtensionsTests: 0.0.0.0 → 127.0.0.1 replacement, port/path preserved,
  non-zero hosts unchanged
- SyncthingVersionInformationTests: regex version parsing, long version string,
  empty/invalid inputs fall back to 0.0.0.0
- SyncthingCapabilitiesTests: capability flags below/at/above threshold,
  default version has no capabilities

Co-authored-by: GermanCoding <4279661+GermanCoding@users.noreply.github.com>
Agent-Logs-Url: https://github.com/GermanCoding/SyncTrayzor/sessions/6115f602-127e-4878-85ea-6239e317c493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants