Path: redb-route/tests/redb.Route.Tests.Sql/Batch/Fakes/CountingExchange.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Sql/Batch/Fakes/CountingExchange.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.Tests.Sql.Batch.Fakes;
/// An exchange that delegates to a real one and counts the linked children created from it.
internal sealed class CountingExchange(Exchange inner) : IExchange
{
/// Calls of .
public int LinkedChildren { get; private set; }
public IMessage In { get => inner.In; set => inner.In = value; }
public IMessage? Out { get => inner.Out; set => inner.Out = value; }
public ExchangePattern Pattern { get => inner.Pattern; set => inner.Pattern = value; }
public IDictionary Properties => inner.Properties;
public Exception? Exception { get => inner.Exception; set => inner.Exception = value; }
public bool ExceptionHandled { get => inner.ExceptionHandled; set => inner.ExceptionHandled = value; }
public string? RouteId { get => inner.RouteId; set => inner.RouteId = value; }
public IRouteContext? Context => ((IExchange)inner).Context;
public IServiceProvider? ServiceProvider => ((IExchange)inner).ServiceProvider;
public string ExchangeId => inner.ExchangeId;
public bool IsStopped => inner.IsStopped;
public T? GetProperty(string key) => inner.GetProperty(key);
public void Stop() => inner.Stop();
public IExchange Clone() => inner.Clone();
public IExchange Snapshot() => inner.Snapshot();
public IExchange CreateLinkedChild(IMessage message)
{
LinkedChildren++;
return inner.CreateLinkedChild(message);
}
public ValueTask DisposeAsync() => ((IAsyncDisposable)inner).DisposeAsync();
}