Path: redb-route/tests/redb.Route.Tests.Amqp/AmqpListRefusalTests.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.Amqp/AmqpListRefusalTests.cs
----
using redb.Route.Abstractions;
using redb.Route.Amqp;
using redb.Route.Core;
namespace redb.Route.Tests.Amqp;
///
/// A list body at the AMQP 1.0 producer: it sends no list, so a list of IMessage is refused with the advice to Split it
/// and a plain list is refused; neither goes out as the type name. Expects ActiveMQ Artemis at localhost:5673.
///
[Trait("Category", "Integration")]
public sealed class AmqpListRefusalTests
{
private const string Connection = "host=localhost&port=5673&user=admin&password=admin";
private static async Task StartProducer(string address)
{
var uri = EndpointUriParser.Parse($"amqp://{address}?{Connection}");
var producer = (AmqpProducer)((AmqpEndpoint)new AmqpComponent().CreateEndpoint(uri)).CreateProducer();
await producer.Start();
return producer;
}
[Fact]
public async Task A_list_of_messages_is_refused_with_the_advice_to_split_it()
{
var producer = await StartProducer($"list.{Guid.NewGuid():N}");
try
{
var act = () => producer.Process(new Exchange(new Message(new List { new Message("a") })));
await act.Should().ThrowAsync().WithMessage("*Split the list*");
}
finally
{
await producer.Stop();
}
}
[Fact]
public async Task A_plain_list_is_refused()
{
var producer = await StartProducer($"list.{Guid.NewGuid():N}");
try
{
var act = () => producer.Process(new Exchange(new Message(new List { 1 })));
await act.Should().ThrowAsync().WithMessage("*List*IMessage*");
}
finally
{
await producer.Stop();
}
}
}