"""Tests verifying game integration wiring in ProcessorDependencies.

Ensures that GameEventBus is properly threaded through to
ColorStripStreamManager and ValueStreamManager.
"""

from wled_controller.core.game_integration.event_bus import GameEventBus
from wled_controller.core.processing.processor_manager import (
    ProcessorDependencies,
    ProcessorManager,
)


class TestGameEventBusWiring:
    """Verify that game_event_bus propagates through ProcessorManager."""

    def test_processor_dependencies_accepts_game_event_bus(self):
        bus = GameEventBus()
        deps = ProcessorDependencies(game_event_bus=bus)
        assert deps.game_event_bus is bus

    def test_css_stream_manager_receives_bus(self):
        bus = GameEventBus()
        deps = ProcessorDependencies(game_event_bus=bus)
        pm = ProcessorManager(deps)
        css_mgr = pm._color_strip_stream_manager
        assert css_mgr._game_event_bus is bus

    def test_value_stream_manager_receives_bus(self):
        """ValueStreamManager is only created when value_source_store is provided."""
        from unittest.mock import MagicMock

        bus = GameEventBus()
        mock_vs_store = MagicMock()
        deps = ProcessorDependencies(
            game_event_bus=bus,
            value_source_store=mock_vs_store,
        )
        pm = ProcessorManager(deps)
        vs_mgr = pm._value_stream_manager
        assert vs_mgr is not None
        assert vs_mgr._event_bus is bus

    def test_without_bus_defaults_to_none(self):
        deps = ProcessorDependencies()
        pm = ProcessorManager(deps)
        assert pm._color_strip_stream_manager._game_event_bus is None
