Skip to content

test: Add 538 AAA pattern unit tests for GeneralUpdate.Core (closes #423)#424

Merged
JusterZhu merged 1 commit into
masterfrom
feature/core-unit-tests
May 25, 2026
Merged

test: Add 538 AAA pattern unit tests for GeneralUpdate.Core (closes #423)#424
JusterZhu merged 1 commit into
masterfrom
feature/core-unit-tests

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Summary

This PR adds 538 unit tests across 9 modules of GeneralUpdate.Core, all following the AAA (Arrange-Act-Assert) pattern. This implements the initial batch of the comprehensive test coverage plan described in Issue #423.

Test Files (17 files)

Module File Tests
Configuration ConfiginfoTests.cs 12
ConfiginfoBuilderTests.cs 19
ConfigurationMapperTests.cs 11
UpdateOptionTests.cs 12
ProcessInfoTests.cs 12
EnvironmentsTests.cs 5
FileSystem FileNodeTests.cs 23
FileTreeTests.cs 10
DefaultBlackListMatcherTests.cs 12
Event EventManagerTests.cs 13
Pipeline PipelineContextTests.cs 11
PipelineBuilderTests.cs 4
Download DownloadPlanBuilderTests.cs 14
DefaultRetryPolicyTests.cs 12
Security AuthProviderTests.cs 11
IPC IpcEncryptionTests.cs 6
GracefulExit GracefulExitTests.cs 1

Coverage Highlights

Configuration

  • \Configinfo.Validate()\ — all 7 required field validations (null/empty/invalid URI)
  • \ConfiginfoBuilder\ — SetXxx null guards, fluent chaining, Build success/failure
  • \ConfigurationMapper\ — source/target null combinations, MapToProcessInfo validation
  • \UpdateOption.ValueOf()\ — singleton pattern, default value preservation
  • \ProcessInfo\ — all 8 null argument checks, downloadTimeOut negative/zero, all properties
  • \Environments\ — AES round-trip, one-time read semantics, special characters

FileSystem

  • \FileNode\ — Add recursion (6 branches), Search (5 paths), SearchParent (6 cases), Equals (7 cases)
  • \FileTree\ — DelNode (7 scenarios: empty/not-found/root-only/leaf/2-children/left-only/right-only)
  • \DefaultBlackListMatcher\ — exact match, glob pattern, format match case-insensitive, directory skip

Other Modules

  • \EventManager\ — listener fault isolation (handler throw doesn't block others), singleton
  • \DownloadPlanBuilder\ — frozen packages, cross-version, MinClientVersion, version ordering
  • \DefaultRetryPolicy\ — 7 exception type categories (OCE/TCE non-retryable, 5xx retryable)
  • \HttpAuthProviderFactory\ — 5 path combinations (Hmac priority, Bearer/ApiKey/NoOp fallback)

Test Results

\
Passed: 538 | Failed: 0 | Skipped: 0 | Total: 538
\\

Test Infrastructure

  • Framework: xUnit 2.x + Moq
  • Target: net10.0
  • Pattern: AAA (Arrange-Act-Assert) with descriptive method names

Next Steps

This is the initial batch (~37% of planned 801 test points). Remaining coverage areas per #423:

  • Strategy (Client/Upgrade/OSS, OS-level)
  • Bootstrap
  • Silent
  • Download (orchestrator, executor, pipeline)
  • Network (VersionService, retry logic)
  • Complete IPC provider chain
  • Compress / HashAlgorithm actual file tests

Closes #423

… FileSystem, Event, Pipeline, Download, Security, IPC, GracefulExit, Compress)

- Configuration: 53 tests (Configinfo.Validate, ConfiginfoBuilder Set/Build, ConfigurationMapper, UpdateOption singleton/equals, ProcessInfo constructor validation, Environments AES round-trip)
- FileSystem: 45 tests (FileNode Add/Search/SearchParent/Equals/GetHashCode, FileTree DelNode all cases, DefaultBlackListMatcher exact/glob/format/dir matching)
- Event: 13 tests (EventManager AddListener/Dispatch/RemoveListener/Clear/fault isolation/singleton)
- Pipeline: 15 tests (PipelineContext Add/Get/Remove/ContainsKey edge cases, PipelineBuilder Build/UseMiddlewareIf)
- Download: 30 tests (DownloadPlanBuilder 14 branches, DefaultRetryPolicy 9 exception types + exponential backoff)
- Security: 11 tests (BearerTokenAuthProvider, ApiKeyAuthProvider, NoOpAuthProvider, HmacAuthProvider, HttpAuthProviderFactory 5 paths)
- IPC: 6 tests (IpcEncryption encrypt/decrypt/delete, EncryptedFileProcessInfoProvider Send/Receive round-trip)
- GracefulExit: 1 test
- HashAlgorithms: stub

All 538 tests pass. Closes #423
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.

Comprehensive Unit Test Coverage for GeneralUpdate.Core — AAA Pattern (801+ Test Points)

1 participant