test: Round 2 — 62 tests for Compress, HashAlgorithms, Download, Network, Strategy modules (closes #425)#426
Merged
Conversation
…Network, Strategy modules - Compress: 12 tests (CompressProvider zip/unknown formats, ZipCompressionStrategy compress/decompress/nested/utf8/rootDir) - HashAlgorithms: 8 tests (Sha256HashAlgorithm ComputeHash/ComputeHashBytes, not-found/same-content/different/large file) - Download: 4 tests (DownloadOrchestratorOptions From/negative timeout/retry, DownloadExecutor/Pipeline structure) - Network: 9 tests (VersionService.SetSslValidationPolicy, StrictSsl/any error, HttpAuthProviderFactory 7 paths) - Strategy: 26 tests (ClientUpdateStrategy/UpgradeUpdateStrategy/OSSUpdateStrategy Create/StartApp/UsePrecheck, CheckPath, IsOssUpgrade logic) All 600 tests pass. Closes #425
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands GeneralUpdate.Core test coverage by adding a second batch of unit tests targeting previously uncovered modules (Compress, HashAlgorithms, Download, Network, Strategy), continuing the test coverage plan from #424/#423 and closing #425.
Changes:
- Add new xUnit test suites for compression (provider + zip strategy) and SHA256 hashing.
- Add complementary coverage for
DownloadOrchestratorOptions.From(...)sanitization behavior. - Add tests for network SSL validation policy + auth provider factory selection and strategy creation/guard behaviors.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/CoreTest/Strategy/StrategyCreationTests.cs | Adds strategy creation/guard tests, plus CheckPath and OSS version comparison tests. |
| tests/CoreTest/Network/VersionServiceAndAuthTests.cs | Adds SSL policy guard/behavior tests and HttpAuthProviderFactory selection tests. |
| tests/CoreTest/HashAlgorithms/Sha256HashAlgorithmTests.cs | Adds file-based SHA256 tests for not-found, determinism, and byte-length. |
| tests/CoreTest/Download/DownloadOrchestratorOptionsComplementaryTests.cs | Adds complementary tests for timeout defaulting and retry-count clamping. |
| tests/CoreTest/Compress/ZipCompressionStrategyTests.cs | Adds zip compress/decompress tests including nested paths, UTF-8, and missing zip handling. |
| tests/CoreTest/Compress/CompressProviderTests.cs | Adds dispatch/exception coverage for CompressProvider compress/decompress format selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+176
to
+183
| // Access protected static CheckPath via subclass | ||
| private static string InvokeCheckPath(AbstractStrategy strategy, string path, string name) | ||
| => WindowsStrategy_CheckPath(path, name); | ||
|
|
||
| [System.Runtime.CompilerServices.MethodImpl( | ||
| System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] | ||
| private static string WindowsStrategy_CheckPath(string path, string name) | ||
| { |
Comment on lines
+202
to
+235
| var result = CompareVersions(cv, sv); | ||
| Assert.False(result); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void IsVersionUpgrade_ClientLower_ReturnsTrue() | ||
| { | ||
| Assert.True(CompareVersions("1.0.0", "2.0.0")); | ||
| Assert.True(CompareVersions("1.9.9", "2.0.0")); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void IsVersionUpgrade_ClientEqualOrHigher_ReturnsFalse() | ||
| { | ||
| Assert.False(CompareVersions("2.0.0", "2.0.0")); | ||
| Assert.False(CompareVersions("3.0.0", "2.0.0")); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void IsVersionUpgrade_InvalidFormat_ReturnsFalse() | ||
| { | ||
| Assert.False(CompareVersions("not.a.version", "2.0.0")); | ||
| Assert.False(CompareVersions("1.0.0", "not.a.version")); | ||
| Assert.False(CompareVersions("abc", "xyz")); | ||
| } | ||
|
|
||
| // Simulates OSSUpdateStrategy.IsOssUpgrade logic | ||
| private static bool CompareVersions(string clientVersion, string serverVersion) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(clientVersion) || string.IsNullOrWhiteSpace(serverVersion)) | ||
| return false; | ||
| return Version.TryParse(clientVersion, out var cv) | ||
| && Version.TryParse(serverVersion, out var sv) | ||
| && cv < sv; |
Comment on lines
+99
to
+100
| var ex = Record.Exception(() => _strategy.Decompress(nonexistent, destDir, Encoding.UTF8)); | ||
| Assert.Null(ex); |
This was referenced May 25, 2026
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
Follow-up to #424. Adds 62 tests across 5 remaining modules, bringing total CoreTest count to 600.
New Files (6 files)
Coverage
Compress (12 tests)
HashAlgorithms (8 tests)
Network (9 tests)
Strategy (26 tests)
Test Results
\
Passed: 600 | Failed: 0 | Total: 600
\\
Closes #425