Path: redb-route/tests/redb.Route.Tests/Idempotent/RepositoryRegistryNameTests.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/Idempotent/RepositoryRegistryNameTests.cs
----
using AwesomeAssertions;
using redb.Route.Abstractions;
using redb.Route.Components;
using redb.Route.Core;
using redb.Route.Processors;
namespace redb.Route.Tests.Idempotent;
///
/// Idempotent and claim-check repositories are found as every other registry reference is: by the bare name, checked
/// for type (Camel's lookupByNameAndType). A bean declared in markup under dedup is the repository
/// repository="#dedup" names; no idempotent: or claimcheck: key prefix exists.
///
public class RepositoryRegistryNameTests : IAsyncLifetime
{
private readonly RouteContext _context = new();
public Task InitializeAsync() => Task.CompletedTask;
public async Task DisposeAsync()
{
await _context.DisposeAsync();
GC.SuppressFinalize(this);
}
// ── Idempotent ────────────────────────────────────────────────────────
[Fact]
public void A_repository_registered_under_its_bare_name_is_found()
{
var repo = new InMemoryIdempotentRepository();
_context.AddToRegistry("dedup", repo);
_context.GetIdempotentRepositoryProvider().Get("dedup").Should().BeSameAs(repo);
_context.GetIdempotentRepositoryProvider().Get("#dedup").Should().BeSameAs(repo, "#name is the registry key as is");
}
[Fact]
public void AddIdempotentRepository_registers_under_the_bare_name()
{
var repo = new InMemoryIdempotentRepository();
_context.AddIdempotentRepository("orders", repo);
_context.GetFromRegistry("orders").Should().BeSameAs(repo);
}
[Fact]
public void Nothing_under_the_name_is_named_as_such_with_the_ways_to_register()
{
var act = () => _context.GetIdempotentRepositoryProvider().Get("missing");
act.Should().Throw()
.WithMessage("*Nothing is registered under 'missing'*AddIdempotentRepository* _context.GetIdempotentRepositoryProvider().Get("dedup");
act.Should().Throw()
.WithMessage("*'dedup'*System.String*not an IIdempotentRepository*");
}
[Fact]
public void TryGet_is_false_for_nothing_and_loud_for_another_type()
{
_context.GetIdempotentRepositoryProvider().TryGet("missing", out _).Should().BeFalse();
_context.AddToRegistry("dedup", 42);
var act = () => _context.GetIdempotentRepositoryProvider().TryGet("dedup", out _);
act.Should().Throw().WithMessage("*System.Int32*");
}
// ── Claim check ───────────────────────────────────────────────────────
[Fact]
public void A_claim_check_repository_is_found_by_its_bare_name()
{
var repo = new InMemoryClaimCheckRepository();
_context.AddToRegistry("payloads", repo);
_context.ResolveClaimCheckRepository("payloads").Should().BeSameAs(repo);
}
[Fact]
public void AddClaimCheckRepository_registers_under_the_bare_name()
{
var repo = new InMemoryClaimCheckRepository();
_context.AddClaimCheckRepository("payloads", repo);
_context.GetFromRegistry("payloads").Should().BeSameAs(repo);
}
[Fact]
public void Another_type_under_a_claim_check_name_is_named_by_its_type()
{
_context.AddToRegistry("payloads", new InMemoryIdempotentRepository());
var act = () => _context.ResolveClaimCheckRepository("payloads");
act.Should().Throw()
.WithMessage("*'payloads'*InMemoryIdempotentRepository*not an IClaimCheckRepository*");
}
[Fact]
public void The_default_claim_check_repository_is_a_context_service_not_a_registry_key()
{
var repo = new InMemoryClaimCheckRepository();
_context.SetDefaultClaimCheckRepository(repo);
_context.ResolveClaimCheckRepository().Should().BeSameAs(repo);
_context.GetService().Should().BeSameAs(repo);
_context.GetFromRegistry