logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class RecordingEventDispatcherService

    IEventDispatcherService implementation that both records every dispatched signal for assertions and delivers it to subscribers, so a test can assert on what a service broadcast and drive an EventDispatcherAction through the same instance.

    Inheritance
    object
    RecordingEventDispatcherService
    Implements
    IEventDispatcherService
    IService
    IFoundationSettings
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Tests.Shared.Fakes
    Assembly: Tests.dll
    Syntax
    public class RecordingEventDispatcherService : IEventDispatcherService, IService, IFoundationSettings
    Remarks

    Every mutation and every snapshot read goes through Serenity.Tests.Shared.Fakes.RecordingEventDispatcherService._recordLock. A fire-and-forget caller such as AchievementService.AttachScreenshotAsync resumes its contended mutation gate on a thread-pool thread once no SynchronizationContext is present (as under NUnit/CoverageRunner), so its final Dispatch call can race a test thread enumerating DispatchedSignals through SignalsOf<TSignal>(). The lock follows the same idiom UnityEventDispatcherService.Dispatch uses in production — snapshot before iterating — so it must not be "simplified" away.

    Constructors

    RecordingEventDispatcherService()

    Declaration
    public RecordingEventDispatcherService()

    Properties

    DispatchedSignals

    Every signal dispatched through this instance, in dispatch order. Each read takes a snapshot copy under the lock, so it is safe to read while a concurrent dispatch is in flight.

    Declaration
    public IReadOnlyList<EventDispatcherSignal> DispatchedSignals { get; }
    Property Value
    Type Description
    IReadOnlyList<EventDispatcherSignal>

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    ReenterOnDispatch

    When set, fires exactly once — on the first call to Dispatch(EventDispatcherSignal, Type) after being set — so a test can stand in for a subscriber that re-enters the dispatcher synchronously (the input-map re-switch that re-fires a held Submit). The callback receives this instance so it can dispatch again; the one-shot latch stops that nested dispatch from re-triggering the callback.

    Declaration
    public Action<RecordingEventDispatcherService> ReenterOnDispatch { get; set; }
    Property Value
    Type Description
    Action<RecordingEventDispatcherService>

    SubscribedSignalTypes

    Every type Subscribe<T>(EventDispatcherSignalDelegate) was called for, in call order and with repeats kept, so a test can assert that a binder subscribed exactly once per type. Each read takes a snapshot copy under the lock.

    Declaration
    public IReadOnlyList<Type> SubscribedSignalTypes { get; }
    Property Value
    Type Description
    IReadOnlyList<Type>

    ThrowOnDispatch

    When set, every call to Dispatch(EventDispatcherSignal, Type) throws this exception instead of recording the signal, so a test can prove a caller releases its guards (locks, gates) from a finally rather than only on the happy path.

    Declaration
    public Exception ThrowOnDispatch { get; set; }
    Property Value
    Type Description
    Exception

    UnsubscribedSignalTypes

    Every type Unsubscribe<T>(EventDispatcherSignalDelegate) was called for, in call order. Each read takes a snapshot copy under the lock.

    Declaration
    public IReadOnlyList<Type> UnsubscribedSignalTypes { get; }
    Property Value
    Type Description
    IReadOnlyList<Type>

    Methods

    Dispatch(IEventDispatcherSignalDefinition)

    Declaration
    public void Dispatch(IEventDispatcherSignalDefinition signalDefinition)
    Parameters
    Type Name Description
    IEventDispatcherSignalDefinition signalDefinition

    Dispatch(EventDispatcherSignal, Type)

    Declaration
    public void Dispatch(EventDispatcherSignal signal, Type type)
    Parameters
    Type Name Description
    EventDispatcherSignal signal
    Type type

    Dispatch<T>(T)

    Declaration
    public void Dispatch<T>(T signal) where T : EventDispatcherSignal
    Parameters
    Type Name Description
    T signal
    Type Parameters
    Name Description
    T

    SignalsOf<TSignal>()

    The signals of a given type dispatched through this instance, in dispatch order.

    Declaration
    public IReadOnlyList<TSignal> SignalsOf<TSignal>() where TSignal : EventDispatcherSignal
    Returns
    Type Description
    IReadOnlyList<TSignal>
    Type Parameters
    Name Description
    TSignal

    The signal type to filter by.

    Subscribe<T>(EventDispatcherSignalDelegate)

    Declaration
    public void Subscribe<T>(EventDispatcherSignalDelegate callback) where T : EventDispatcherSignal
    Parameters
    Type Name Description
    EventDispatcherSignalDelegate callback
    Type Parameters
    Name Description
    T

    Unsubscribe<T>(EventDispatcherSignalDelegate)

    Declaration
    public void Unsubscribe<T>(EventDispatcherSignalDelegate callback) where T : EventDispatcherSignal
    Parameters
    Type Name Description
    EventDispatcherSignalDelegate callback
    Type Parameters
    Name Description
    T

    Implements

    IEventDispatcherService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved