Strengthen F1Server.Tests packet coverage (2020-2026) - #587
Merged
Conversation
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.
|
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
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:Assert.AreEqualcomparisons.if/elsepattern where a failed precondition only asserted header nullity instead of the real expectation, replacing it with hard preconditions followed by an unconditional assertion.F12021HeaderSize/F12022HeaderSizeconstants matching the per-year pattern already used from 2023 onward.PacketProcessor20XXTestsclasses genuine year-specific coverage instead of repeating the same generic type/instance check.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).WheelSurfacetype check (is ICarTelemetryYYYYvs. the concreteis CarTelemetryYYYYused 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 --checkclean, anddotnet testfiltered to that year's test classes, all passing) before being combined onto this branch. The fullF1Server.Testssuite (1064 tests) passes after the combined change.