Path: redb-route/tests/redb.Route.Tests/Components/SedaComponentTests.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/Components/SedaComponentTests.cs
----
using AwesomeAssertions;
using redb.Route.Abstractions;
using redb.Route.Components;
using redb.Route.Core;
namespace redb.Route.Tests.Components;
///
/// Tests for the SEDA (Staged Event-Driven Architecture) component.
///
public class SedaComponentTests : IAsyncLifetime
{
private readonly RouteContext _context = new();
public Task InitializeAsync() => Task.CompletedTask;
public async Task DisposeAsync()
{
await _context.DisposeAsync();
GC.SuppressFinalize(this);
}
[Fact]
public void Component_HasCorrectScheme()
{
var component = new SedaComponent();
component.Scheme.Should().Be("seda");
}
[Fact]
public void CreateEndpoint_ReturnsSedaEndpoint()
{
var component = new SedaComponent();
var uri = EndpointUriParser.Parse("seda://myqueue");
var endpoint = component.CreateEndpoint(uri);
endpoint.Should().BeOfType();
}
[Fact]
public void CreateEndpoint_SameUri_ReturnsSameInstance()
{
var component = new SedaComponent();
var uri1 = EndpointUriParser.Parse("seda://myqueue");
var uri2 = EndpointUriParser.Parse("seda://myqueue");
var ep1 = component.CreateEndpoint(uri1);
var ep2 = component.CreateEndpoint(uri2);
ep1.Should().BeSameAs(ep2);
}
[Fact]
public void Endpoint_Unbounded_ReturnsNegativeOneForQueueSize()
{
var component = new SedaComponent();
var uri = EndpointUriParser.Parse("seda://test?size=0");
var endpoint = (SedaEndpoint)component.CreateEndpoint(uri);
// Unbounded channels don't support Count, so CurrentQueueSize returns -1
endpoint.CurrentQueueSize.Should().Be(-1);
}
[Fact]
public void Options_DefaultValues()
{
var opts = new SedaEndpointOptions();
opts.ResolvedConcurrentConsumers.Should().Be(1, "the default stays 1, as in Camel/Spring/Azure");
opts.Size.Should().Be(1000, "bounded by default, as Camel's seda: an unbounded queue is an explicit size=0");
opts.Timeout.Should().Be(30000);
}
[Fact]
public void Endpoint_WithoutSize_IsBounded()
{
var component = new SedaComponent();
var endpoint = (SedaEndpoint)component.CreateEndpoint(EndpointUriParser.Parse("seda://default-bound"));
endpoint.CurrentQueueSize.Should().Be(0, "a bounded queue counts its items; an unbounded one reports -1");
}
[Fact]
public void Options_Validate_ThrowsOnInvalidConcurrentConsumers()
{
var opts = new SedaEndpointOptions { ConcurrentConsumers = "0" };
var act = () => opts.Validate();
act.Should().Throw().WithMessage("*concurrentConsumers*");
}
[Fact]
public void Options_Validate_ThrowsOnNegativeSize()
{
var opts = new SedaEndpointOptions { Size = -1 };
var act = () => opts.Validate();
act.Should().Throw();
}
[Fact]
public async Task Seda_AsyncDelivery_ProducerReturnsImmediately()
{
var received = new List