Path: redb-route/tests/redb.Route.Tests/Core/ListBodyTests.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/Core/ListBodyTests.cs ---- using System.Text.Json.Nodes; using AwesomeAssertions; using redb.Route.Abstractions; using redb.Route.Core; namespace redb.Route.Tests.Core; /// A list body at a producer: what is a list of messages, what is a plain list, and the exchange of one element. public class ListBodyTests { [Fact] public void A_list_of_messages_is_recognised() { var body = new List { new Message("a"), new Message("b") }; ListBody.Messages(body).Should().HaveCount(2); ListBody.IsPlainList(body).Should().BeFalse(); } [Theory] [MemberData(nameof(PlainLists))] public void A_collection_without_a_text_form_is_a_plain_list(object body) => ListBody.IsPlainList(body).Should().BeTrue(); public static TheoryData PlainLists => new() { new List { 1 }, new object[] { "a" }, new HashSet { "x" } }; [Theory] [MemberData(nameof(NotLists))] public void Text_bytes_and_collections_that_write_themselves_are_not_plain_lists(object body) { ListBody.IsPlainList(body).Should().BeFalse(); ListBody.Messages(body).Should().BeNull(); } public static TheoryData NotLists => new() { "text", new byte[] { 1 }, new JsonArray(1, 2), 42 }; [Fact] public void A_message_element_is_a_copy_with_its_own_headers_and_none_of_the_parents() { var parent = new Exchange(new Message("parent")); parent.In.Headers["parent-header"] = "p"; parent.Properties["prop"] = "kept"; var element = new Message("one") { ContentType = "text/plain" }; element.Headers["key"] = "k1"; var child = ListBody.ElementExchange(parent, element); child.In.Body.Should().Be("one"); child.In.ContentType.Should().Be("text/plain"); child.In.Headers.Should().ContainKey("key").And.NotContainKey("parent-header"); child.In.Should().NotBeSameAs(element); child.Properties["prop"].Should().Be("kept"); } [Fact] public void A_plain_element_is_the_body_under_the_parents_headers() { var parent = new Exchange(new Message(new List { 7 }) { ContentType = "application/json" }); parent.In.Headers["parent-header"] = "p"; var child = ListBody.ElementExchange(parent, 7); child.In.Body.Should().Be(7); child.In.Headers["parent-header"].Should().Be("p"); child.In.ContentType.Should().Be("application/json"); } [Fact] public void The_refusals_name_the_endpoint_and_the_way_out() { ListBody.RequestReplyRefusal("rabbitmq://q", 3).Message.Should().Contain("rabbitmq://q").And.Contain("Split the list"); ListBody.PlainListRefusal("wmq://Q", new List()).Message.Should().Contain("wmq://Q").And.Contain("List").And.Contain("IMessage"); } }