Skip to content

test: add AAAT unit tests for GeneralUpdate.Core uncovered areas - #430

Merged
JusterZhu merged 2 commits into
masterfrom
feature/core-unit-tests-aaat
May 25, 2026
Merged

test: add AAAT unit tests for GeneralUpdate.Core uncovered areas#430
JusterZhu merged 2 commits into
masterfrom
feature/core-unit-tests-aaat

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Closes #429

Summary

Add comprehensive unit tests following the AAAT (Arrange-Act-Assert-TearDown) paradigm for previously uncovered areas in GeneralUpdate.Core.

New test files (3)

File Tests Covers
\Configuration/ObjectTranslatorTests.cs\ 6 \GetPacketHash\ with tracing on/off, null, type checks
\Hubs/RandomRetryPolicyTests.cs\ 8 SignalR retry within/after 60s window, boundary, distribution
\Configuration/VersionModelTests.cs\ 16 \VersionInfo/\VersionOSS/\BaseResponseDTO\ JSON round-trip, defaults

Modified test files (5)

File Change
\EventManagerTests.cs\ Added \IDisposable\ TearDown (replaces ad-hoc Clear())
\EventListenerTests.cs\ Same \IDisposable\ TearDown pattern
\EventListenerBatchTests.cs\ Same pattern; removed manual try/finally
\EventManagerConcurrencyTests.cs\ Same pattern; removed manual cleanup
\ProcessInfoTests.cs\ +8 tests: encoding variants, optional params, default ctor, blacklist

Test Results

674/674 tests pass (0 failures, 0 errors)

- Add ObjectTranslatorTests: GetPacketHash with tracing on/off, null, type checks
- Add RandomRetryPolicyTests: SignalR retry within/after 60s window, distribution
- Add VersionModelTests: VersionInfo/VersionOSS/BaseResponseDTO JSON round-trip
- Extend ProcessInfoTests: encoding variants, optional params, default ctor, blacklist
- Refactor EventManagerTests: add IDisposable TearDown for singleton isolation
- Refactor EventListenerTests/EventListenerBatchTests/EventManagerConcurrencyTests: same pattern

All 674 tests pass (0 failures).
Copilot AI review requested due to automatic review settings May 25, 2026 16:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds AAAT-style unit tests to increase coverage of previously uncovered areas in GeneralUpdate.Core, plus refactors several event-related tests to use consistent per-test teardown for singleton state.

Changes:

  • Added new unit test suites for RandomRetryPolicy, ObjectTranslator.GetPacketHash, and configuration DTO/model JSON behavior.
  • Expanded ProcessInfo tests to cover additional constructor scenarios (encodings, optional params, defaults, blacklist params).
  • Refactored multiple event tests to use IDisposable teardown to clear EventManager singleton state after each test.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/CoreTest/Hubs/RandomRetryPolicyTests.cs New tests covering retry delay behavior and boundaries for RandomRetryPolicy.
tests/CoreTest/Configuration/ObjectTranslatorTests.cs New tests covering ObjectTranslator.GetPacketHash behavior under tracing on/off and input variants.
tests/CoreTest/Configuration/VersionModelTests.cs New tests covering JSON round-trips and defaults for version/config DTOs.
tests/CoreTest/Event/EventManagerTests.cs Converted to AAAT style and added IDisposable teardown to clear singleton state.
tests/CoreTest/Event/EventManagerConcurrencyTests.cs Added IDisposable teardown and simplified cleanup relying on Clear().
tests/CoreTest/Event/EventListenerTests.cs Added IDisposable teardown to clear singleton state for isolation.
tests/CoreTest/Event/EventListenerBatchTests.cs Added AAAT structure and IDisposable teardown; simplified manual cleanup.
tests/CoreTest/Configuration/ProcessInfoTests.cs Added additional constructor tests for encodings, defaults, nullable params, multi-version inputs, and blacklist lists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +35
Assert.NotNull(delay);
Assert.True(delay >= TimeSpan.Zero,
$"Expected delay >= 0, but got {delay}");
Assert.True(delay <= TimeSpan.FromSeconds(10),
$"Expected delay <= 10 seconds, but got {delay?.TotalSeconds}s");
Comment on lines +53 to +56
Assert.NotNull(delay);
Assert.True(delay >= TimeSpan.Zero);
Assert.True(delay <= TimeSpan.FromSeconds(10));
}
Comment on lines +72 to +75
// Assert
Assert.NotNull(delay);
Assert.True(delay <= TimeSpan.FromSeconds(10));
}
Comment on lines +183 to +186
// Assert
Assert.NotNull(delay);
Assert.True(delay <= TimeSpan.FromSeconds(10));
}
Comment on lines +13 to +18
[Fact]
public void GetPacketHash_ValidVersionInfo_ReturnsFormattedHash()
{
// Arrange
GeneralTracer.SetTracingEnabled(true);
var version = new VersionInfo { Hash = "abc123def" };
Comment on lines 106 to 110
Task.WaitAll(tasks);

// Assert — no exceptions thrown during concurrent operations
Assert.True(true);
}
Comment on lines +270 to +276

/// <summary>TearDown: cleanup temp files if any were created.</summary>
private static void CleanupTempFile(string path)
{
try { if (File.Exists(path)) File.Delete(path); }
catch { /* best-effort */ }
}
- RandomRetryPolicyTests: use delay!.Value instead of nullable comparison
- ObjectTranslatorTests: add IDisposable to restore GeneralTracer global state
- EventListenerBatchTests: replace Assert.True(true) with Record.Exception
- ProcessInfoTests: remove unused CleanupTempFile helper
@JusterZhu
JusterZhu merged commit d5f5a72 into master May 25, 2026
3 checks passed
@JusterZhu
JusterZhu deleted the feature/core-unit-tests-aaat branch May 25, 2026 16:38
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.

Add AAAT-based unit tests for GeneralUpdate.Core uncovered areas

2 participants