Namespace Serenity.UnityModal.Tests.Infrastructure
Classes
ModalOptionSignalDispatcherTests
Tests for ModalOptionSignalDispatcher: each submit signal reaches the event dispatcher
exactly once per press, even when one of those signals re-fires the same submit synchronously — the
input-map switch that produced the modal double submit. Exemplar:
UnityMenuSubmitServiceTests (its TestSignal / capturing dispatcher / MakeOption shape).
StubModalComponent
The Unity-lifetime counterpart of UnityModalServiceTests.StubModal: a modal that can actually be
destroyed, which is what a real modal is and what the plain C# stub can never be. Only a
UnityEngine.Object reaches the "destroyed but not null" state the close-modal guard exists
for, so this is the fixture that pins UnityObjectUtils.IsAlive against a plain == null
check. Lives in its own file because Unity binds a MonoBehaviour script by file name.
TestableModalService
Opens UnityModalService's protected close-modal handler to
UnityModalServiceTests, which is the only way to exercise it without a live event
dispatcher and a real modal prefab. Lives in its own file because Unity binds a
MonoBehaviour script by file name; nothing else may use it.
UnityModalComponentFactoryTests
Tests for UnityModalComponentFactory's value-persistence logic (SetOptionValue and
the bounds/null guards of ShiftOptionValue) and the CreateUiComponent validation guards.
The component-mutating branches of ShiftOptionValue require a real interactable component and are
covered only through their early-return guards here.
UnityModalOptionsBuilderTests
Tests for CreateModalOptions(IReadOnlyList<UiOption>, IUiThemeDefinition). Only the option-free guard path is unit-testable without real prefab templates: a null options list returns an empty interactable list before the component creator is ever touched (so it is safe to pass a null creator). Rendering actual options requires a populated UI theme and prefab hierarchy and is left to PlayMode/scene coverage.
UnityModalServiceTests
Tests for ShouldUseOptionsPipeline(OnShowModalInput), the branch that decides whether ShowModal(OnShowModalInput) renders the rich UiOption pipeline or falls back to the legacy button factory, and for the close-modal handler's nothing-to-close guard. The rest of ShowModal builds a real UI component hierarchy from a theme's prefab templates and is left to PlayMode/scene coverage; these decisions are the pieces that are safe and meaningful to isolate.
UnityShowModalComponentFactoryTests
Tests for CreateComponent<Element, Parameters, Actions>(Parameters, Actions): it must create a GameObject,
attach a UnityShowModalComponent, push parameters into it, and return the attached element.