Skip to content

Fix HeadlessAudioPlayer recorded method name strings (docs/plans/phase-2-consistency-fixes.md Phase 1) #12

@JohnLudlow

Description

@JohnLudlow

Overview

Correct a latent bug in HeadlessAudioPlayer where StartPlayback records the string "Play" and StopPlayback records the string "Stop". These stale strings date from an earlier interface naming pass. Any test asserting call.Method == "StartPlayback" or call.Method == "StopPlayback" will currently fail.

The fix is a two-line string literal change plus a unit test to prevent regression.

Plan issue

Plan status

Not started

Definition of terms

Term Meaning
Recorded call A tuple (string Method, string AudioAssetId, object? Arg) appended to HeadlessAudioPlayer.RecordedCalls each time a playback method is invoked.

Architectural considerations and constraints

  • Only string literals change. The tuple structure (string Method, string AudioAssetId, object? Arg) is preserved unchanged.
  • SetVolume records "SetVolume" — correct, no change required.
  • The fix is entirely inside HeadlessAudioPlayer.cs; no other files need changing beyond the new test file.

Implementation guide

Plan requirements

  • (Not started) Recorded method name for StartPlayback is "StartPlayback"

    • GIVEN a HeadlessAudioPlayer
    • WHEN StartPlayback("sfx", false) is called
    • THEN RecordedCalls[0].Method == "StartPlayback"
  • (Not started) Recorded method name for StopPlayback is "StopPlayback"

    • GIVEN a HeadlessAudioPlayer
    • WHEN StopPlayback("sfx") is called
    • THEN the resulting entry has Method == "StopPlayback"

Phase 1 — Fix string literals and add regression test

Not started

Objective

Change lines 19 and 23 of HeadlessAudioPlayer.cs. Add a unit test in HeadlessAudioPlayerTests.cs (creating the file if absent) that asserts both method name values.

Technical details

Method Current recorded string Correct recorded string
StartPlayback "Play" "StartPlayback"
StopPlayback "Stop" "StopPlayback"
SetVolume "SetVolume" No change required

File: src/GameEngineAdapter.Headless/HeadlessAudioPlayer.cs, lines 19 and 23.

Phase requirements

  • (Not started) Build succeeds after string literal change

    • GIVEN the corrected source
    • WHEN dotnet build is run
    • THEN the solution builds without errors or warnings
  • (Not started) New unit test passes

    • GIVEN the corrected HeadlessAudioPlayer
    • WHEN the new unit test runs
    • THEN all assertions pass

Examples

Before:

// src/GameEngineAdapter.Headless/HeadlessAudioPlayer.cs

public void StartPlayback(string audioAssetId, bool loopPlayback = false) =>
    _recordedCalls.Add(("Play", audioAssetId, loopPlayback));

public void StopPlayback(string audioAssetId) =>
    _recordedCalls.Add(("Stop", audioAssetId, null));

After:

// src/GameEngineAdapter.Headless/HeadlessAudioPlayer.cs

public void StartPlayback(string audioAssetId, bool loopPlayback = false) =>
    _recordedCalls.Add(("StartPlayback", audioAssetId, loopPlayback));

public void StopPlayback(string audioAssetId) =>
    _recordedCalls.Add(("StopPlayback", audioAssetId, null));

New test:

// src/GameEngineAdapter.UnitTests/HeadlessAudioPlayerTests.cs

public sealed class HeadlessAudioPlayerTests
{
    [Fact]
    public void StartPlayback_RecordsCorrectMethodName()
    {
        var player = new HeadlessAudioPlayer();
        player.StartPlayback("sfx", false);
        Assert.Equal("StartPlayback", player.RecordedCalls[0].Method);
    }

    [Fact]
    public void StopPlayback_RecordsCorrectMethodName()
    {
        var player = new HeadlessAudioPlayer();
        player.StopPlayback("sfx");
        Assert.Equal("StopPlayback", player.RecordedCalls[0].Method);
    }
}

See also

Metadata

Metadata

Assignees

Labels

area-libItems related to reusable librariesarea-technicalsystemsInternal systems to do with game developmentenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions