Skip to content

Strengthen F1Server.Tests packet coverage (2020-2026) - #587

Merged
LarsLaskowski merged 11 commits into
mainfrom
claude/fix-multiple-issues-fk9wpk
Aug 15, 2026
Merged

Strengthen F1Server.Tests packet coverage (2020-2026)#587
LarsLaskowski merged 11 commits into
mainfrom
claude/fix-multiple-issues-fk9wpk

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses a batch of low-severity test-quality findings from the repository review (docs/review/FINDINGS-OVERVIEW.md) across the F1 2020-2026 packet test classes:

  • Replaces exact float/double equality checks with delta-based Assert.AreEqual comparisons.
  • Removes a defensive if/else pattern where a failed precondition only asserted header nullity instead of the real expectation, replacing it with hard preconditions followed by an unconditional assertion.
  • Adds missing content assertions for FinalClassification, LapData, Participants and Event packets that previously only checked object type/non-null.
  • Fixes packet header-size checks that referenced a misleadingly-named constant from an earlier year; adds dedicated F12021HeaderSize/F12022HeaderSize constants matching the per-year pattern already used from 2023 onward.
  • Gives structurally near-duplicate PacketProcessor20XXTests classes genuine year-specific coverage instead of repeating the same generic type/instance check.
  • Extends SessionProcessorTests [DataRow] coverage so the existing 2026 gearbox-assist branch actually executes, and adds the session-processor lookup test to the years that were missing it; along the way this surfaced and fixed a real test-isolation bug (shared static session state leaking a flag between test methods).
  • Fixes an inconsistent WheelSurface type check (is ICarTelemetryYYYY vs. the concrete is CarTelemetryYYYY used by sibling tests in the same file).

Linked issues

Closes #310
Closes #313
Closes #315
Closes #318
Closes #319
Closes #320
Closes #326
Closes #327
Closes #328
Closes #333
Closes #334
Closes #339
Closes #340
Closes #341
Closes #342

Review notes

Each year's changes were developed and validated independently (build with 0 RH#### warnings, reihitsu-format --check clean, and dotnet test filtered to that year's test classes, all passing) before being combined onto this branch. The full F1Server.Tests suite (1064 tests) passes after the combined change.

claude and others added 11 commits August 15, 2026 06:45
F1 2021 and 2022 test classes referenced ConstData.F12020HeaderSize for
their packet header length checks. The value is correct (24 bytes,
unchanged since 2020), but the name is misleading in 2021/2022 tests.
Adds F12021HeaderSize and F12022HeaderSize, matching the per-year
constant pattern already used for the 29-byte header from 2023 onward.
The .claude/worktrees/ directory holds temporary git worktrees created
by background agent sessions and should never be tracked.
Replaces exact float/double equality checks with delta-based
Assert.AreEqual calls in the car status, car telemetry, and event
value tests, and flattens the defensive if/else precondition pattern
across all F1-2020 test methods into hard precondition asserts
followed by the real assertion. The previous else branches only
asserted header nullity, masking the actual expectation whenever a
precondition failed.
Adds year-specific processor coverage (session caching, frame and
timestamp updates), concrete final classification content checks,
and Platform/IsShowOnlineNames participant assertions. Float equality
checks now use a delta tolerance instead of exact comparison, and the
mismatched if/else fallback in final classification and session
history tests is replaced with flat preconditions.
Uses the F12022HeaderSize constant instead of the misleadingly named
F12020HeaderSize in packet length checks. Adds a tolerance to the
float comparison in the fuel remaining laps assertion. Extends final
classification coverage with concrete position, points, laps and
tyre stint assertions, and adds session-processor coverage tied to
the actual F1 2022 game version and frame bookkeeping. Flattens the
defensive if/else fallback in final classification and session
history tests into hard preconditions followed by the real assertion.
Adds a DataRow(2026) case to ProcessSessionPacketExpectedGearBoxAssistChanged
so its existing 2026 branch actually executes. The 2026 sample session
baseline stores GearBoxAssistFirst as Unknown while the raw session packet's
GearboxAssist is Auto, so any earlier 2026 test sharing the static session
data could already flip GearBoxAssistChanged before this test's precondition
check; the test now resets that flag explicitly to stay deterministic
regardless of execution order.

Adds ReceiveProcessorExpectedSessionProcessor2020 through 2023, matching the
existing 2024-2026 pattern, since ProcessorFactory routes session packets to
SessionProcessor purely by packet type and sample data exists for all years.
Adds genuine 2025-specific processor coverage (session caching, frame
identifier tracking, session-change invalidation) instead of duplicating
the generic session-processor checks. Asserts concrete lap data time,
delta and warning fields, and final classification position, points,
penalties and tyre stint values instead of only checking object types.
Replaces exact float equality checks with delta-based comparisons, and
flattens the defensive if/else precondition pattern across all F1 2025
value tests into hard preconditions followed by unconditional asserts.
Adds real 2024-specific coverage to PacketProcessor2024Tests beyond the
generic session-processor check, covering every 2024 packet type mapping
and processor caching. Extends float/double comparisons in car status,
car telemetry and event tests to use a delta-based AreEqual instead of
exact equality. Adds concrete content assertions to
PacketFinalClassification2024Tests (position, laps, points, tyre
stints) and a TechLevel assertion to PacketParticipants2024Tests.
Flattens the defensive if/else header-check fallback in
PacketFinalClassification2024Tests and PacketSessionHistory2024Tests
into hard preconditions followed by unconditional assertions.
Adds real content assertions to the 2026 lap data and final classification
tests (time, delta, warning, position, points, and tyre stint fields),
extends session start event coverage with the detail fields available from
the single SessionStart sample, and gives the 2026 processor factory tests
genuine per-packet-type and frame-identifier coverage instead of duplicating
the generic session-processor checks. Converts float comparisons to
AreEqual with an explicit delta in car status and car telemetry, and
replaces the defensive if/else fallback in final classification and
session history with flat preconditions followed by unconditional
assertions, using small helper methods to read the parsed packet data.

Full parity with the 2025 event test class (TopSpeed, Flashback, penalty
details) is not achievable for 2026 because only a SessionStart sample
packet exists in SampleData; the added assertions cover every field that
sample actually carries.
Length checks in the F1-2021 test classes referenced
ConstData.F12020HeaderSize even though the byte value is identical.
Switches every occurrence to the dedicated F12021HeaderSize constant
so the code reads correctly for the game version under test.
Enforced MSTest analyzer rules as errors in .editorconfig (MSTEST0037, MSTEST0038, MSTEST0039, MSTEST0049, MSTEST0065, MSTEST0068). Replaced Assert.IsTrue checks for length equality with Assert.AreEqual in packet test classes for clearer intent and assertion messages. Updated a string containment assertion in PacketParticipants2025Tests to use Assert.Contains for MSTest compliance. Refactored TimerManagerTests to use Wait overloads with TestContext.CancellationToken and replaced Thread.Sleep with cancellation-aware waiting for improved test cancellation support.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@LarsLaskowski
LarsLaskowski merged commit c6de585 into main Aug 15, 2026
5 of 6 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/fix-multiple-issues-fk9wpk branch August 15, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment