Path: redb-route/tests/redb.Route.Tests/Definitions/F8DefinitionTests.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/Definitions/F8DefinitionTests.cs
----
using AwesomeAssertions;
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Definitions;
using redb.Route.Processors;
namespace redb.Route.Tests.Definitions;
///
/// Tests for W5 F8 — AggregateDefinition, ThrottleDefinition, DebounceDefinition, CircuitBreakerDefinition.
///
public class F8DefinitionTests : IAsyncLifetime
{
private readonly RouteContext _context = new();
public Task InitializeAsync() => Task.CompletedTask;
public async Task DisposeAsync()
{
await _context.DisposeAsync();
GC.SuppressFinalize(this);
}
private static Exchange MakeExchange(object? body = null)
=> new Exchange(new Message { Body = body });
// ── AggregateDefinition — structure ───────────────────────────────────────
[Fact]
public void Aggregate_ReturnsAggregateDefinition()
{
var route = new RouteDefinition();
var agg = route.Aggregate(_ => "key", (old, @new) => @new, _ => false);
agg.Should().BeOfType();
}
[Fact]
public void Aggregate_SetsParentOnDefinition()
{
var route = new RouteDefinition();
var agg = route.Aggregate(_ => "key", (old, @new) => @new, _ => false);
agg.Parent.Should().BeSameAs(route);
}
[Fact]
public void Aggregate_IsAddedToRouteOutputs()
{
var route = new RouteDefinition();
route.Aggregate(_ => "key", (old, @new) => @new, _ => false);
route.Outputs.Should().HaveCount(1);
route.Outputs[0].Should().BeOfType();
}
[Fact]
public void EndAggregate_ReturnsParentRoute()
{
var route = new RouteDefinition();
var back = route.Aggregate(_ => "k", (o, n) => n, _ => true).EndAggregate();
back.Should().BeSameAs(route);
}
// ── AggregateDefinition — runtime ─────────────────────────────────────────
[Fact]
public async Task Aggregate_CompletedGroup_ForwardsToTargetPipeline()
{
var received = new List