Bundle: redb-route / tests/redb.Route.Tests.Ftp (tests.redb.Route.Tests.Ftp.txt), 12 files Snapshot: 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 Index: https://redbase.app/src/dev-2026-12-06/redb-route/_index.txt ==== Path: redb-route/tests/redb.Route.Tests.Ftp/FtpBuilderTests.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.Ftp/FtpBuilderTests.cs ---- using redb.Route.Core; using redb.Route.Expressions; using FtpDsl = redb.Route.Ftp.Ftp; namespace redb.Route.Tests.Ftp; public class FtpBuilderTests { private static ConstantExpression C(string s) => new(s); // ── Factory ───────────────────────────────────────────────────── [Fact] public void Directory_StartsWithFtpScheme() { var uri = FtpDsl.Directory("/incoming").Build(); uri.Should().StartWith("ftp:///incoming"); } [Fact] public void NullPath_Throws() { var act = () => FtpDsl.Directory(null!); act.Should().Throw(); } [Fact] public void EmptyPath_Throws() { var act = () => FtpDsl.Directory(""); act.Should().Throw(); } // ── Connection ────────────────────────────────────────────────── [Fact] public void Host_SetsParam() { var uri = FtpDsl.Directory("/d").Host(C("ftp.example.com")).Build(); uri.Should().Contain("host=ftp.example.com"); } [Fact] public void Port_SetsParam() { var uri = FtpDsl.Directory("/d").Port(2121).Build(); uri.Should().Contain("port=2121"); } [Fact] public void Username_SetsParam() { var uri = FtpDsl.Directory("/d").Username(C("admin")).Build(); uri.Should().Contain("username=admin"); } [Fact] public void Password_SetsParam() { var uri = FtpDsl.Directory("/d").Password(C("secret")).Build(); uri.Should().Contain("password=secret"); } [Fact] public void PassiveMode_SetsParam() { var uri = FtpDsl.Directory("/d").PassiveMode().Build(); uri.Should().Contain("passiveMode=true"); } [Fact] public void ActiveMode_SetsParam() { var uri = FtpDsl.Directory("/d").ActiveMode().Build(); uri.Should().Contain("passiveMode=false"); } // ── TLS ───────────────────────────────────────────────────────── [Fact] public void UseFtps_SetsParam() { var uri = FtpDsl.Directory("/d").UseFtps().Build(); uri.Should().Contain("useFtps=true"); } [Fact] public void ValidateCertificate_SetsParam() { var uri = FtpDsl.Directory("/d").ValidateCertificate(false).Build(); uri.Should().Contain("validateCertificate=false"); } // ── Consumer ──────────────────────────────────────────────────── [Fact] public void Include_SetsParam() { var uri = FtpDsl.Directory("/d").Include("*.csv").Build(); uri.Should().Contain("include=%2A.csv"); } [Fact] public void Exclude_SetsParam() { var uri = FtpDsl.Directory("/d").Exclude("*.tmp").Build(); uri.Should().Contain("exclude=%2A.tmp"); } [Fact] public void Recursive_SetsParam() { var uri = FtpDsl.Directory("/d").Recursive().Build(); uri.Should().Contain("recursive=true"); } [Fact] public void Delay_SetsParam() { var uri = FtpDsl.Directory("/d").Delay(5000).Build(); uri.Should().Contain("delay=5000"); } [Fact] public void SortBy_SetsParam() { var uri = FtpDsl.Directory("/d").SortBy("name").Build(); uri.Should().Contain("sortBy=name"); } [Fact] public void MaxMessagesPerPoll_SetsParam() { var uri = FtpDsl.Directory("/d").MaxMessagesPerPoll(10).Build(); uri.Should().Contain("maxMessagesPerPoll=10"); } // ── Post-processing ───────────────────────────────────────────── [Fact] public void Noop_SetsParam() { var uri = FtpDsl.Directory("/d").Noop().Build(); uri.Should().Contain("noop=true"); } [Fact] public void Delete_SetsParam() { var uri = FtpDsl.Directory("/d").Delete().Build(); uri.Should().Contain("delete=true"); } [Fact] public void MoveTo_SetsParam() { var uri = FtpDsl.Directory("/d").MoveTo(C("/done")).Build(); uri.Should().Contain("moveTo="); } [Fact] public void Idempotent_SetsParam() { var uri = FtpDsl.Directory("/d").Idempotent().Build(); uri.Should().Contain("idempotent=true"); } // ── Producer ──────────────────────────────────────────────────── [Fact] public void AutoCreate_SetsParam() { var uri = FtpDsl.Directory("/d").AutoCreate().Build(); uri.Should().Contain("autoCreate=true"); } [Fact] public void TempPrefix_SetsParam() { var uri = FtpDsl.Directory("/d").TempPrefix(C(".tmp")).Build(); uri.Should().Contain("tempPrefix=.tmp"); } [Fact] public void Flatten_SetsParam() { var uri = FtpDsl.Directory("/d").Flatten().Build(); uri.Should().Contain("flatten=true"); } [Fact] public void TransferType_SetsParam() { var uri = FtpDsl.Directory("/d").TransferType("Ascii").Build(); uri.Should().Contain("transferType=Ascii"); } // ── Conversion ────────────────────────────────────────────────── [Fact] public void ImplicitConversion_ReturnsUri() { string uri = FtpDsl.Directory("/incoming").Host(C("ftp.example.com")).Username(C("admin")); uri.Should().StartWith("ftp:///incoming?"); } [Fact] public void ToString_ReturnsSameAsBuild() { var builder = FtpDsl.Directory("/d").Host(C("h")).Include("*.csv"); builder.ToString().Should().Be(builder.Build()); } // ── Full chain ────────────────────────────────────────────────── [Fact] public void FullChain_Consumer_BuildsCorrectUri() { var uri = FtpDsl.Directory("/incoming") .Host(C("ftp.example.com")) .Port(21) .Username(C("admin")) .Password(C("secret")) .Include("*.csv") .Recursive() .Delete() .Delay(5000) .Build(); uri.Should().StartWith("ftp:///incoming?"); uri.Should().Contain("host=ftp.example.com"); uri.Should().Contain("include=%2A.csv"); uri.Should().Contain("recursive=true"); uri.Should().Contain("delete=true"); } [Fact] public void FullChain_Producer_BuildsCorrectUri() { var uri = FtpDsl.Directory("/outgoing") .Host(C("ftp.example.com")) .Username(C("admin")) .Password(C("secret")) .AutoCreate() .TempPrefix(C(".uploading-")) .Build(); uri.Should().StartWith("ftp:///outgoing?"); uri.Should().Contain("autoCreate=true"); } // ── Round-trip ────────────────────────────────────────────────── [Fact] public void RoundTrip_ParseAndReconstruct() { var original = FtpDsl.Directory("/data").Host(C("ftp.example.com")).Include("*.csv").Build(); var parsed = EndpointUriParser.Parse(original); parsed.Scheme.Should().Be("ftp"); parsed.RawParameters["host"].Should().Be("ftp.example.com"); parsed.RawParameters["include"].Should().Be("*.csv"); } // ── StreamBody ────────────────────────────────────────────────── [Fact] public void StreamBody_SetsParam() { var uri = FtpDsl.Directory("/data").StreamBody().Build(); uri.Should().Contain("streamBody=true"); } [Fact] public void StreamBody_RoundTrip() { var uri = FtpDsl.Directory("/data").StreamBody().Build(); var parsed = EndpointUriParser.Parse(uri); parsed.RawParameters["streamBody"].Should().Be("true"); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpComponentTests.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.Ftp/FtpComponentTests.cs ---- using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; public sealed class FtpComponentTests { [Fact] public void Scheme_IsFtp() { var component = new FtpComponent(); component.Scheme.Should().Be("ftp"); } [Fact] public void CreateEndpoint_ReturnsCorrectType() { var component = new FtpComponent(); var uri = CreateUri("/upload", new Dictionary { ["host"] = "myserver" }); var endpoint = component.CreateEndpoint(uri); endpoint.Should().BeOfType(); } [Fact] public void CreateEndpoint_NullUri_Throws() { var component = new FtpComponent(); var act = () => component.CreateEndpoint(null!); act.Should().Throw(); } [Fact] public void CreateEndpoint_ParsesRemotePath() { var component = new FtpComponent(); var uri = CreateUri("/upload/data", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); endpoint.RemotePath.Should().Be("/upload/data"); } [Fact] public void CreateEndpoint_EmptyPath_DefaultsToRoot() { var component = new FtpComponent(); var uri = CreateUri("", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); endpoint.RemotePath.Should().Be("/"); } [Fact] public void CreateEndpoint_NormalizesDoubleSlashes() { var component = new FtpComponent(); var uri = CreateUri("/upload//data//", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); endpoint.RemotePath.Should().Be("/upload/data"); } [Fact] public void CreateEndpoint_BindsOptionsFromUri() { var component = new FtpComponent(); var uri = CreateUri("/upload", new Dictionary { ["host"] = "ftp.company.com", ["port"] = "2121", ["username"] = "admin", ["password"] = "secret", ["delay"] = "5000", ["include"] = "*.csv", ["noop"] = "true" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); var opts = endpoint.EndpointOptions; opts.Host.Should().Be("ftp.company.com"); opts.Port.Should().Be(2121); opts.Username.Should().Be("admin"); opts.Password.Should().Be("secret"); opts.Delay.Should().Be(5000); opts.Include.Should().Be("*.csv"); opts.Noop.Should().BeTrue(); } [Fact] public void CreateEndpoint_InvalidOptions_Throws() { var component = new FtpComponent(); var uri = CreateUri("/upload", new Dictionary { ["host"] = "" }); var act = () => component.CreateEndpoint(uri); act.Should().Throw(); } [Fact] public void CreateEndpoint_CreatesProducer() { var component = new FtpComponent(); var uri = CreateUri("/upload", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); var producer = endpoint.CreateProducer(); producer.Should().BeOfType(); } [Fact] public void CreateEndpoint_CreatesConsumer() { var component = new FtpComponent(); var uri = CreateUri("/upload", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); var processor = Substitute.For(); var consumer = endpoint.CreateConsumer(processor); consumer.Should().BeOfType(); } [Fact] public void CreateEndpoint_NullProcessor_Throws() { var component = new FtpComponent(); var uri = CreateUri("/upload", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); var act = () => endpoint.CreateConsumer(null!); act.Should().Throw(); } [Fact] public void CreateEndpoint_PathWithoutLeadingSlash_Normalized() { var component = new FtpComponent(); var uri = CreateUri("upload", new Dictionary { ["host"] = "myserver" }); var endpoint = (FtpEndpoint)component.CreateEndpoint(uri); endpoint.RemotePath.Should().Be("/upload"); } private static EndpointUri CreateUri(string path, Dictionary parameters) { return new EndpointUri("ftp", path, $"ftp://{path}", parameters); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpConnectionFactoryLoudTests.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.Ftp/FtpConnectionFactoryLoudTests.cs ---- using redb.Route.Core; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; /// /// A set-but-unknown connectionFactory name must fail loud — /// never silently fall back to URI parameters. /// public sealed class FtpConnectionFactoryLoudTests { [Fact] public async Task ConnectionFactoryTypo_FailsLoud() { await using var ctx = new RouteContext(); ctx.AddComponent(new FtpComponent()); var act = () => ctx.GetEndpoint("ftp://host/inbox?connectionFactory=typo-name&username=u&password=p"); act.Should().Throw() .Which.Message.Should().Contain("typo-name"); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpConnectionFactoryTests.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.Ftp/FtpConnectionFactoryTests.cs ---- using redb.Route.Core; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; /// /// FTP server credentials must be able to live in the registry instead of the endpoint URI, /// so they never reach logs, telemetry, or the dashboard. /// public sealed class FtpConnectionFactoryTests { private const string Secret = "ftpP4ssw0rd"; private static FtpComponent Wire(string name, FtpConnectionFactory factory) { var context = new RouteContext(); var component = new FtpComponent(); context.AddComponent(component); context.AddToRegistry(name, factory); return component; } [Fact] public void Factory_SuppliesCredentials_WhenUriCarriesNone() { var component = Wire("partner-ftp", new FtpConnectionFactory { Host = "ftp.partner.com", Port = 2121, Username = "svc-drop", Password = Secret, UseFtps = true }); var uri = EndpointUriParser.Parse("ftp://inbox?connectionFactory=partner-ftp"); var endpoint = component.CreateEndpoint(uri); endpoint.Should().NotBeNull(); uri.ToUriString().Should().NotContain(Secret); uri.ToString().Should().NotContain(Secret); } [Fact] public void ExplicitUriValue_WinsOverFactory() { var component = Wire("f", new FtpConnectionFactory { Host = "from-factory", Username = "factory-user", Port = 2121 }); var uri = EndpointUriParser.Parse( "ftp://inbox?connectionFactory=f&host=from-uri&username=uri-user"); component.CreateEndpoint(uri).Should().NotBeNull(); uri.RawParameters["host"].Should().Be("from-uri"); uri.RawParameters["username"].Should().Be("uri-user"); } [Fact] public void MissingFactory_FailsLoud() { var context = new RouteContext(); var component = new FtpComponent(); context.AddComponent(component); var uri = EndpointUriParser.Parse("ftp://inbox?connectionFactory=absent&host=direct"); var act = () => component.CreateEndpoint(uri); // A typo in connectionFactory must fail loud, not fall back silently act.Should().Throw() .Which.Message.Should().Contain("absent"); } [Fact] public void Dsl_EmitsConnectionFactory() { var uri = redb.Route.Ftp.Ftp.Directory("/inbox").ConnectionFactory("partner-ftp").Build(); uri.Should().Contain("connectionFactory=partner-ftp"); uri.Should().NotContain("password="); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpConsumerCancellationTests.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.Ftp/FtpConsumerCancellationTests.cs ---- using System.Text; using FluentFTP; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; /// /// A cancellation coming out of the route that is not the consumer's own stop — an HttpClient timeout comes as a /// — is a failure of that file: it goes down the failure path, moveFailed /// included. It used to escape the per-file handling and fail the whole poll, so the file stayed where it was. /// Expects FTP at localhost:21 (testuser/secret). /// [Trait("Category", "Integration")] public sealed class FtpConsumerCancellationTests { private const string Host = "localhost"; private const int Port = 21; private const string Username = "testuser"; private const string Password = "secret"; [Fact] public async Task A_cancellation_out_of_the_route_moves_the_file_to_moveFailed() { var dir = $"cancel-{Guid.NewGuid():N}"; using var client = new AsyncFtpClient(Host, Username, Password, Port); await client.Connect(); using (var content = new MemoryStream(Encoding.UTF8.GetBytes("payload"))) await client.UploadStream(content, $"/{dir}/a.txt", FtpRemoteExists.Overwrite, true); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(Task.FromException(new TaskCanceledException("a call inside the route timed out"))); var uri = EndpointUriParser.Parse( $"ftp:///{dir}?host={Host}&port={Port}&username={Username}&password={Password}" + "&delay=200&initialDelay=10&moveFailed=.failed"); var consumer = ((FtpEndpoint)new FtpComponent().CreateEndpoint(uri)).CreateConsumer(processor); await consumer.Start(); var deadline = DateTime.UtcNow.AddSeconds(10); while (DateTime.UtcNow < deadline && !await client.FileExists($"/{dir}/.failed/a.txt")) await Task.Delay(200); await consumer.Stop(); (await client.FileExists($"/{dir}/.failed/a.txt")).Should().BeTrue("the failed file goes down the failure path"); (await client.FileExists($"/{dir}/a.txt")).Should().BeFalse(); await client.DeleteFile($"/{dir}/.failed/a.txt"); await client.DeleteDirectory($"/{dir}/.failed"); await client.DeleteDirectory($"/{dir}"); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpEndpointOptionsTests.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.Ftp/FtpEndpointOptionsTests.cs ---- using redb.Route.GenericFile; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; public sealed class FtpEndpointOptionsTests { // ── Defaults ──────────────────────────────────────────────────── [Fact] public void Defaults_Connection_AreCorrect() { var opts = new FtpEndpointOptions(); opts.Host.Should().Be("localhost"); opts.Port.Should().Be(21); opts.Username.Should().BeEmpty(); opts.Password.Should().BeEmpty(); opts.ConnectionTimeout.Should().Be(30_000); opts.OperationTimeout.Should().Be(60_000); opts.PassiveMode.Should().BeTrue(); } [Fact] public void Defaults_Tls_AreCorrect() { var opts = new FtpEndpointOptions(); opts.UseFtps.Should().BeFalse(); opts.ValidateCertificate.Should().BeTrue(); } [Fact] public void Defaults_Transfer_AreCorrect() { var opts = new FtpEndpointOptions(); opts.TransferType.Should().Be(FtpTransferType.Binary); opts.IgnoreFileNotFoundOrPermissionError.Should().BeFalse(); } [Fact] public void Defaults_Reconnection_AreCorrect() { var opts = new FtpEndpointOptions(); opts.MaximumReconnectAttempts.Should().Be(3); opts.ReconnectDelay.Should().Be(1000); opts.Disconnect.Should().BeFalse(); } [Fact] public void Defaults_Consumer_AreCorrect() { var opts = new FtpEndpointOptions(); opts.Delay.Should().Be(60_000); opts.InitialDelay.Should().Be(1000); opts.Include.Should().BeEmpty(); opts.Exclude.Should().BeEmpty(); opts.Recursive.Should().BeFalse(); opts.MaxDepth.Should().Be(0); opts.MinDepth.Should().Be(0); opts.SortBy.Should().Be(GenericFileSortBy.None); opts.MaxMessagesPerPoll.Should().Be(0); opts.MinAge.Should().Be(0); opts.MaxAge.Should().Be(0); opts.Noop.Should().BeFalse(); opts.Delete.Should().BeFalse(); opts.MoveTo.Should().BeEmpty(); opts.MoveExisting.Should().Be(GenericFileExistStrategy.Override); opts.PreMove.Should().BeEmpty(); opts.MoveFailed.Should().BeEmpty(); opts.Idempotent.Should().BeFalse(); opts.IdempotentKey.Should().BeEmpty(); opts.DoneFileName.Should().BeEmpty(); opts.Charset.Should().Be("utf-8"); opts.StartingDirectoryMustExist.Should().BeTrue(); opts.SendEmptyMessageWhenIdle.Should().BeFalse(); } [Fact] public void Defaults_Producer_AreCorrect() { var opts = new FtpEndpointOptions(); opts.FileName.Should().BeNull(); opts.FileExist.Should().Be(GenericFileExistStrategy.Override); opts.MoveExistingFileStrategy.Should().Be(FtpMoveExistingStrategy.Timestamp); opts.TempPrefix.Should().BeEmpty(); opts.TempFileName.Should().BeEmpty(); opts.AutoCreate.Should().BeTrue(); opts.AllowNullBody.Should().BeFalse(); opts.EagerDeleteTargetFile.Should().BeTrue(); opts.Flatten.Should().BeFalse(); opts.JailStartingDirectory.Should().BeTrue(); opts.AppendChars.Should().BeEmpty(); } // ── Validation passes ─────────────────────────────────────────── [Fact] public void Validate_MinimalValidOptions_Succeeds() { var opts = new FtpEndpointOptions { Host = "myserver" }; var act = () => opts.Validate(); act.Should().NotThrow(); } [Fact] public void Validate_WithCredentials_Succeeds() { var opts = new FtpEndpointOptions { Host = "myserver", Username = "admin", Password = "secret" }; var act = () => opts.Validate(); act.Should().NotThrow(); } // ── Connection validation ─────────────────────────────────────── [Fact] public void Validate_EmptyHost_Throws() { var opts = new FtpEndpointOptions { Host = "" }; var act = () => opts.Validate(); act.Should().Throw().WithMessage("*Host*"); } [Fact] public void Validate_WhitespaceHost_Throws() { var opts = new FtpEndpointOptions { Host = " " }; var act = () => opts.Validate(); act.Should().Throw().WithMessage("*Host*"); } [Theory] [InlineData(0)] [InlineData(-1)] [InlineData(65536)] [InlineData(100000)] public void Validate_InvalidPort_Throws(int port) { var opts = new FtpEndpointOptions { Host = "h", Port = port }; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("Port"); } [Theory] [InlineData(1)] [InlineData(21)] [InlineData(2121)] [InlineData(65535)] public void Validate_ValidPort_Succeeds(int port) { var opts = new FtpEndpointOptions { Host = "h", Port = port }; var act = () => opts.Validate(); act.Should().NotThrow(); } // ── Consumer validation ───────────────────────────────────────── [Fact] public void Validate_NegativeDelay_Throws() { var opts = ValidOptions(); opts.Delay = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("Delay"); } [Fact] public void Validate_NegativeInitialDelay_Throws() { var opts = ValidOptions(); opts.InitialDelay = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("InitialDelay"); } [Fact] public void Validate_NoopAndDelete_Throws() { var opts = ValidOptions(); opts.Noop = true; opts.Delete = true; var act = () => opts.Validate(); act.Should().Throw().WithMessage("*Noop*Delete*"); } [Fact] public void Validate_NoopAndMoveTo_Throws() { var opts = ValidOptions(); opts.Noop = true; opts.MoveTo = ".done"; var act = () => opts.Validate(); act.Should().Throw().WithMessage("*Noop*MoveTo*"); } [Fact] public void Validate_DeleteAndMoveTo_Throws() { var opts = ValidOptions(); opts.Delete = true; opts.MoveTo = ".done"; var act = () => opts.Validate(); act.Should().Throw().WithMessage("*Delete*MoveTo*"); } [Fact] public void Validate_NegativeMaxMessagesPerPoll_Throws() { var opts = ValidOptions(); opts.MaxMessagesPerPoll = -5; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("MaxMessagesPerPoll"); } [Fact] public void Validate_NegativeMaxDepth_Throws() { var opts = ValidOptions(); opts.MaxDepth = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("MaxDepth"); } [Fact] public void Validate_NegativeMinDepth_Throws() { var opts = ValidOptions(); opts.MinDepth = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("MinDepth"); } [Fact] public void Validate_NegativeMinAge_Throws() { var opts = ValidOptions(); opts.MinAge = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("MinAge"); } [Fact] public void Validate_NegativeMaxAge_Throws() { var opts = ValidOptions(); opts.MaxAge = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("MaxAge"); } // ── Timeout validation ────────────────────────────────────────── [Fact] public void Validate_NegativeConnectionTimeout_Throws() { var opts = ValidOptions(); opts.ConnectionTimeout = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("ConnectionTimeout"); } [Fact] public void Validate_NegativeOperationTimeout_Throws() { var opts = ValidOptions(); opts.OperationTimeout = -1; var act = () => opts.Validate(); act.Should().Throw().Which.ParamName.Should().Be("OperationTimeout"); } // ── Post-processing combinations ──────────────────────────────── [Fact] public void Validate_NoopOnly_Succeeds() { var opts = ValidOptions(); opts.Noop = true; var act = () => opts.Validate(); act.Should().NotThrow(); } [Fact] public void Validate_DeleteOnly_Succeeds() { var opts = ValidOptions(); opts.Delete = true; var act = () => opts.Validate(); act.Should().NotThrow(); } [Fact] public void Validate_MoveToOnly_Succeeds() { var opts = ValidOptions(); opts.MoveTo = ".done"; var act = () => opts.Validate(); act.Should().NotThrow(); } // ── BindFromUri ───────────────────────────────────────────────── [Fact] public void BindFromUri_SetsConnectionOptions() { var opts = new FtpEndpointOptions(); opts.BindFromUri(new Dictionary { ["host"] = "myserver.com", ["port"] = "2121", ["username"] = "admin", ["password"] = "secret123", ["connectionTimeout"] = "5000", ["operationTimeout"] = "10000", ["passiveMode"] = "false" }); opts.Host.Should().Be("myserver.com"); opts.Port.Should().Be(2121); opts.Username.Should().Be("admin"); opts.Password.Should().Be("secret123"); opts.ConnectionTimeout.Should().Be(5000); opts.OperationTimeout.Should().Be(10000); opts.PassiveMode.Should().BeFalse(); } [Fact] public void BindFromUri_SetsTlsOptions() { var opts = new FtpEndpointOptions(); opts.BindFromUri(new Dictionary { ["useFtps"] = "true", ["validateCertificate"] = "false" }); opts.UseFtps.Should().BeTrue(); opts.ValidateCertificate.Should().BeFalse(); } [Fact] public void BindFromUri_SetsConsumerOptions() { var opts = new FtpEndpointOptions(); opts.BindFromUri(new Dictionary { ["delay"] = "5000", ["initialDelay"] = "2000", ["include"] = "*.csv", ["exclude"] = "*.tmp", ["recursive"] = "true", ["maxDepth"] = "3", ["sortBy"] = "Name", ["maxMessagesPerPoll"] = "10", ["minAge"] = "5000", ["maxAge"] = "60000", ["noop"] = "true", ["idempotent"] = "true", ["doneFileName"] = "${file:name}.done", ["sendEmptyMessageWhenIdle"] = "true" }); opts.Delay.Should().Be(5000); opts.InitialDelay.Should().Be(2000); opts.Include.Should().Be("*.csv"); opts.Exclude.Should().Be("*.tmp"); opts.Recursive.Should().BeTrue(); opts.MaxDepth.Should().Be(3); opts.SortBy.Should().Be(GenericFileSortBy.Name); opts.MaxMessagesPerPoll.Should().Be(10); opts.MinAge.Should().Be(5000); opts.MaxAge.Should().Be(60000); opts.Noop.Should().BeTrue(); opts.Idempotent.Should().BeTrue(); opts.DoneFileName.Should().Be("${file:name}.done"); opts.SendEmptyMessageWhenIdle.Should().BeTrue(); } [Fact] public void BindFromUri_SetsProducerOptions() { var opts = new FtpEndpointOptions(); opts.BindFromUri(new Dictionary { ["fileExist"] = "Fail", ["tempPrefix"] = ".redb_", ["autoCreate"] = "true", ["allowNullBody"] = "true", ["eagerDeleteTargetFile"] = "false", ["flatten"] = "true", ["jailStartingDirectory"] = "false" }); opts.FileExist.Should().Be(GenericFileExistStrategy.Fail); opts.TempPrefix.Should().Be(".redb_"); opts.AutoCreate.Should().BeTrue(); opts.AllowNullBody.Should().BeTrue(); opts.EagerDeleteTargetFile.Should().BeFalse(); opts.Flatten.Should().BeTrue(); opts.JailStartingDirectory.Should().BeFalse(); } [Fact] public void BindFromUri_SetsReconnectionOptions() { var opts = new FtpEndpointOptions(); opts.BindFromUri(new Dictionary { ["maximumReconnectAttempts"] = "5", ["reconnectDelay"] = "2000", ["disconnect"] = "true" }); opts.MaximumReconnectAttempts.Should().Be(5); opts.ReconnectDelay.Should().Be(2000); opts.Disconnect.Should().BeTrue(); } // ── Helper ────────────────────────────────────────────────────── private static FtpEndpointOptions ValidOptions() => new() { Host = "myserver" }; } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpEnumsTests.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.Ftp/FtpEnumsTests.cs ---- using redb.Route.GenericFile; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; public sealed class FtpEnumsTests { [Fact] public void GenericFileExistStrategy_HasExpectedValues() { Enum.GetNames().Should() .BeEquivalentTo("Override", "Append", "Fail", "Ignore", "Move", "TryRename"); } [Fact] public void GenericFileSortBy_HasExpectedValues() { Enum.GetNames().Should() .BeEquivalentTo("None", "Name", "NameDesc", "Modified", "ModifiedDesc", "Size", "SizeDesc"); } [Fact] public void FtpTransferType_HasExpectedValues() { Enum.GetNames().Should() .BeEquivalentTo("Binary", "Ascii"); } [Fact] public void FtpMoveExistingStrategy_HasExpectedValues() { Enum.GetNames().Should() .BeEquivalentTo("Backup", "Timestamp", "Guid"); } [Theory] [InlineData(GenericFileExistStrategy.Override, 0)] [InlineData(GenericFileExistStrategy.Append, 1)] [InlineData(GenericFileExistStrategy.Fail, 2)] [InlineData(GenericFileExistStrategy.Ignore, 3)] [InlineData(GenericFileExistStrategy.Move, 4)] [InlineData(GenericFileExistStrategy.TryRename, 5)] public void GenericFileExistStrategy_IntValues_AreStable(GenericFileExistStrategy strategy, int expected) { ((int)strategy).Should().Be(expected); } [Theory] [InlineData(GenericFileSortBy.None, 0)] [InlineData(GenericFileSortBy.Name, 1)] [InlineData(GenericFileSortBy.NameDesc, 2)] [InlineData(GenericFileSortBy.Modified, 3)] [InlineData(GenericFileSortBy.ModifiedDesc, 4)] [InlineData(GenericFileSortBy.Size, 5)] [InlineData(GenericFileSortBy.SizeDesc, 6)] public void GenericFileSortBy_IntValues_AreStable(GenericFileSortBy sort, int expected) { ((int)sort).Should().Be(expected); } [Theory] [InlineData(FtpTransferType.Binary, 0)] [InlineData(FtpTransferType.Ascii, 1)] public void FtpTransferType_IntValues_AreStable(FtpTransferType type, int expected) { ((int)type).Should().Be(expected); } [Theory] [InlineData(FtpMoveExistingStrategy.Backup, 0)] [InlineData(FtpMoveExistingStrategy.Timestamp, 1)] [InlineData(FtpMoveExistingStrategy.Guid, 2)] public void FtpMoveExistingStrategy_IntValues_AreStable(FtpMoveExistingStrategy strategy, int expected) { ((int)strategy).Should().Be(expected); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpHeadersTests.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.Ftp/FtpHeadersTests.cs ---- using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; public sealed class FtpHeadersTests { [Fact] public void AllHeaders_HaveCorrectPrefix() { var headerFields = typeof(FtpHeaders) .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) .Where(f => f.FieldType == typeof(string) && f.Name != nameof(FtpHeaders.Prefix)) .ToList(); headerFields.Should().NotBeEmpty(); foreach (var field in headerFields) { var val = (string)field.GetValue(null)!; val.Should().StartWith(FtpHeaders.Prefix, $"header {field.Name} should start with '{FtpHeaders.Prefix}'"); } } [Fact] public void Prefix_IsCorrect() { FtpHeaders.Prefix.Should().Be("redbFtp."); } [Fact] public void AllHeaders_AreUnique() { var headerFields = typeof(FtpHeaders) .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) .Where(f => f.FieldType == typeof(string)) .Select(f => (string)f.GetValue(null)!) .ToList(); headerFields.Should().OnlyHaveUniqueItems(); } [Fact] public void KnownConsumerHeaders_ExistAndCorrect() { FtpHeaders.FileName.Should().Be("redbFtp.Name"); FtpHeaders.FileNameOnly.Should().Be("redbFtp.NameOnly"); FtpHeaders.FileExtension.Should().Be("redbFtp.Extension"); FtpHeaders.RemotePath.Should().Be("redbFtp.RemotePath"); FtpHeaders.RelativePath.Should().Be("redbFtp.RelativePath"); FtpHeaders.RemoteParent.Should().Be("redbFtp.RemoteParent"); FtpHeaders.FileLength.Should().Be("redbFtp.Length"); FtpHeaders.FileLastModified.Should().Be("redbFtp.LastModified"); FtpHeaders.Host.Should().Be("redbFtp.Host"); FtpHeaders.Port.Should().Be("redbFtp.Port"); FtpHeaders.Username.Should().Be("redbFtp.Username"); } [Fact] public void ProducerHeaders_ExistAndCorrect() { FtpHeaders.FileNameProduced.Should().Be("redbFtp.NameProduced"); } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpIntegrationTests.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.Ftp/FtpIntegrationTests.cs ---- using System.Collections.Concurrent; using System.Text; using FluentFTP; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Ftp; using Xunit.Abstractions; namespace redb.Route.Tests.Ftp; /// /// Integration tests against delfer/alpine-ftp-server docker container. /// Expects FTP at localhost:21 (testuser/secret). /// Start with: docker compose -f docker-compose.tests.yml up ftp -d /// [Trait("Category", "Integration")] public sealed class FtpIntegrationTests : IAsyncLifetime { private const string Host = "localhost"; private const int Port = 21; private const string Username = "testuser"; private const string Password = "secret"; private readonly ITestOutputHelper _output; public FtpIntegrationTests(ITestOutputHelper output) => _output = output; public Task InitializeAsync() => Task.CompletedTask; public Task DisposeAsync() => Task.CompletedTask; // ───── Helpers ───── private static string UniqueDir() => $"test-{Guid.NewGuid():N}"; private FtpEndpoint CreateEndpoint(string remotePath, string? extraParams = null) { var qs = $"host={Host}&port={Port}&username={Username}&password={Password}"; if (extraParams is not null) qs += $"&{extraParams}"; var uri = EndpointUriParser.Parse($"ftp:///{remotePath}?{qs}"); return (FtpEndpoint)new FtpComponent().CreateEndpoint(uri); } private async Task CreateRawClientAsync() { var client = new AsyncFtpClient(Host, Username, Password, Port); await client.Connect().ConfigureAwait(false); return client; } private async Task CleanupDirAsync(AsyncFtpClient client, string path) { if (!await client.DirectoryExists(path).ConfigureAwait(false)) return; var items = await client.GetListing(path, FtpListOption.AllFiles).ConfigureAwait(false); foreach (var item in items) { if (item.Type == FtpObjectType.Directory) await CleanupDirAsync(client, item.FullName).ConfigureAwait(false); else await client.DeleteFile(item.FullName).ConfigureAwait(false); } await client.DeleteDirectory(path).ConfigureAwait(false); } private async Task SeedFileAsync(AsyncFtpClient client, string path, string content) { using var ms = new MemoryStream(Encoding.UTF8.GetBytes(content)); await client.UploadStream(ms, path, FtpRemoteExists.Overwrite, true).ConfigureAwait(false); } private async Task ReadFileAsync(AsyncFtpClient client, string path) { using var ms = new MemoryStream(); await client.DownloadStream(ms, path).ConfigureAwait(false); return Encoding.UTF8.GetString(ms.ToArray()); } // ───── Producer Tests ───── [Fact] public async Task Producer_UploadsTextFile() { var dir = UniqueDir(); var remotePath = $"{dir}"; _output.WriteLine($"Remote: {remotePath}"); var ep = CreateEndpoint(remotePath, "autoCreate=true"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message("Hello FTP!")); exchange.In.Headers[FtpHeaders.FileName] = "hello.txt"; await producer.Process(exchange); await producer.Stop(); exchange.In.Headers[FtpHeaders.FileNameProduced].Should().NotBeNull(); using var client = await CreateRawClientAsync(); var filePath = $"/{remotePath}/hello.txt"; (await client.FileExists(filePath)).Should().BeTrue(); var content = await ReadFileAsync(client, filePath); content.Should().Be("Hello FTP!"); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_UploadsBinaryFile() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var data = new byte[] { 0x00, 0x01, 0xFF, 0xFE, 0x42, 0x99 }; var exchange = new Exchange(new Message(data)); exchange.In.Headers[FtpHeaders.FileName] = "binary.bin"; await producer.Process(exchange); await producer.Stop(); using var client = await CreateRawClientAsync(); using var ms = new MemoryStream(); await client.DownloadStream(ms, $"/{remotePath}/binary.bin"); ms.ToArray().Should().BeEquivalentTo(data); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_TempPrefix_AtomicUpload() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&tempPrefix=.redb_"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message("atomic content")); exchange.In.Headers[FtpHeaders.FileName] = "atomic.txt"; await producer.Process(exchange); await producer.Stop(); using var client = await CreateRawClientAsync(); (await client.FileExists($"/{remotePath}/atomic.txt")).Should().BeTrue(); // No temp files left var items = await client.GetListing($"/{remotePath}"); items.Where(i => i.Name.StartsWith(".redb_")).Should().BeEmpty(); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_FileExistFail_ThrowsOnDuplicate() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&fileExist=Fail"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var ex1 = new Exchange(new Message("first")); ex1.In.Headers[FtpHeaders.FileName] = "dup.txt"; await producer.Process(ex1); var ex2 = new Exchange(new Message("second")); ex2.In.Headers[FtpHeaders.FileName] = "dup.txt"; var act = () => producer.Process(ex2); await act.Should().ThrowAsync(); await producer.Stop(); using var client = await CreateRawClientAsync(); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_FileExistIgnore_KeepsOriginal() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&fileExist=Ignore"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var ex1 = new Exchange(new Message("original")); ex1.In.Headers[FtpHeaders.FileName] = "keep.txt"; await producer.Process(ex1); var ex2 = new Exchange(new Message("ignored")); ex2.In.Headers[FtpHeaders.FileName] = "keep.txt"; await producer.Process(ex2); await producer.Stop(); using var client = await CreateRawClientAsync(); var content = await ReadFileAsync(client, $"/{remotePath}/keep.txt"); content.Should().Be("original"); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_FileExistOverride_Overwrites() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&fileExist=Override"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var ex1 = new Exchange(new Message("v1")); ex1.In.Headers[FtpHeaders.FileName] = "over.txt"; await producer.Process(ex1); var ex2 = new Exchange(new Message("v2")); ex2.In.Headers[FtpHeaders.FileName] = "over.txt"; await producer.Process(ex2); await producer.Stop(); using var client = await CreateRawClientAsync(); var content = await ReadFileAsync(client, $"/{remotePath}/over.txt"); content.Should().Be("v2"); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_AutoCreateNestedDirs() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message("deep")); exchange.In.Headers[FtpHeaders.FileName] = "sub/nested/deep.txt"; await producer.Process(exchange); await producer.Stop(); using var client = await CreateRawClientAsync(); (await client.FileExists($"/{remotePath}/sub/nested/deep.txt")).Should().BeTrue(); await CleanupDirAsync(client, $"/{remotePath}"); } // ───── Consumer Tests ───── [Fact] public async Task Consumer_ReceivesUploadedFile() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/sample.txt", "Hello from FTP"); var ep = CreateEndpoint(remotePath, "noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); var rx = received.First(); rx.In.Headers[FtpHeaders.FileName].Should().Be("sample.txt"); rx.In.Headers[FtpHeaders.FileNameOnly].Should().Be("sample"); rx.In.Headers[FtpHeaders.FileExtension].Should().Be(".txt"); rx.In.Headers[FtpHeaders.Host].Should().Be(Host); rx.In.Headers[FtpHeaders.Port].Should().Be(Port); rx.In.Headers[FtpHeaders.Username].Should().Be(Username); ((long)rx.In.Headers[FtpHeaders.FileLength]!).Should().BeGreaterThan(0); var body = Encoding.UTF8.GetString((byte[])rx.In.Body!); body.Should().Be("Hello from FTP"); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_Delete_RemovesFileAfterProcessing() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/deleteme.txt", "delete me"); var ep = CreateEndpoint(remotePath, "delete=true&delay=500&initialDelay=100"); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); (await rawClient.FileExists($"{fullDir}/deleteme.txt")).Should().BeFalse(); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_MoveTo_MovesFileAfterProcessing() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await rawClient.CreateDirectory($"{fullDir}/.done", true); await SeedFileAsync(rawClient, $"{fullDir}/moveme.txt", "move me"); var ep = CreateEndpoint(remotePath, $"moveTo=.done&delay=500&initialDelay=100"); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); (await rawClient.FileExists($"{fullDir}/moveme.txt")).Should().BeFalse(); (await rawClient.FileExists($"{fullDir}/.done/moveme.txt")).Should().BeTrue(); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_IncludeFilter_FiltersFiles() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/report.csv", "csv data"); await SeedFileAsync(rawClient, $"{fullDir}/notes.txt", "text data"); var ep = CreateEndpoint(remotePath, "include=*.csv&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); ((string)received.First().In.Headers[FtpHeaders.FileName]!).Should().Be("report.csv"); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_ExcludeFilter_SkipsMatchingFiles() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/keep.txt", "keep"); await SeedFileAsync(rawClient, $"{fullDir}/skip.log", "skip"); var ep = CreateEndpoint(remotePath, "exclude=*.log&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); ((string)received.First().In.Headers[FtpHeaders.FileName]!).Should().Be("keep.txt"); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_Recursive_ReadsSubdirectories() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await rawClient.CreateDirectory($"{fullDir}/sub", true); await SeedFileAsync(rawClient, $"{fullDir}/root.txt", "root"); await SeedFileAsync(rawClient, $"{fullDir}/sub/child.txt", "child"); var ep = CreateEndpoint(remotePath, "recursive=true&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var counter = 0; var done = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); if (Interlocked.Increment(ref counter) >= 2) done.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(done.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(2); received.Select(r => (string)r.In.Headers[FtpHeaders.FileName]!) .Should().BeEquivalentTo(["root.txt", "child.txt"]); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_MaxMessagesPerPoll_LimitsFiles() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); for (int i = 0; i < 5; i++) await SeedFileAsync(rawClient, $"{fullDir}/file-{i}.txt", $"file-{i}"); var ep = CreateEndpoint(remotePath, "maxMessagesPerPoll=2&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var counter = 0; var done = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); if (Interlocked.Increment(ref counter) >= 2) done.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(done.Task, Task.Delay(10_000)); await Task.Delay(200); await consumer.Stop(); received.Count.Should().BeGreaterThanOrEqualTo(2); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_Idempotent_NoReprocessing() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/stable.txt", "idempotent data"); var ep = CreateEndpoint(remotePath, "idempotent=true&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(10_000)); await Task.Delay(2000); await consumer.Stop(); received.Should().HaveCount(1); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_EmptyDirectory_NoMessages() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); await rawClient.CreateDirectory($"/{remotePath}", true); var ep = CreateEndpoint(remotePath, "noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.Delay(2000); await consumer.Stop(); received.Should().BeEmpty(); await CleanupDirAsync(rawClient, $"/{remotePath}"); } [Fact] public async Task Consumer_SortByName_OrderedOutput() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); foreach (var name in new[] { "charlie.txt", "alpha.txt", "bravo.txt" }) await SeedFileAsync(rawClient, $"{fullDir}/{name}", name); var ep = CreateEndpoint(remotePath, "sortBy=Name&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var counter = 0; var done = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); if (Interlocked.Increment(ref counter) >= 3) done.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(done.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(3); var names = received.Select(r => (string)r.In.Headers[FtpHeaders.FileName]!) .ToList(); names.Should().BeEquivalentTo(["alpha.txt", "bravo.txt", "charlie.txt"]); await CleanupDirAsync(rawClient, fullDir); } // ───── Roundtrip Tests ───── [Fact] public async Task Producer_To_Consumer_FullRoundtrip() { var dir = UniqueDir(); var remotePath = $"{dir}"; _output.WriteLine($"Roundtrip dir: {remotePath}"); var prodEp = CreateEndpoint(remotePath, "autoCreate=true"); var producer = (FtpProducer)prodEp.CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message("roundtrip content")); exchange.In.Headers[FtpHeaders.FileName] = "roundtrip.txt"; await producer.Process(exchange); await producer.Stop(); var consEp = CreateEndpoint(remotePath, "delete=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)consEp.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); var rx = received.First(); rx.In.Headers[FtpHeaders.FileName].Should().Be("roundtrip.txt"); var body = Encoding.UTF8.GetString((byte[])rx.In.Body!); body.Should().Be("roundtrip content"); using var rawClient = await CreateRawClientAsync(); (await rawClient.FileExists($"/{remotePath}/roundtrip.txt")).Should().BeFalse(); await CleanupDirAsync(rawClient, $"/{remotePath}"); } [Fact] public async Task Producer_To_Consumer_MultipleFiles() { var dir = UniqueDir(); var remotePath = $"{dir}"; const int fileCount = 5; var prodEp = CreateEndpoint(remotePath, "autoCreate=true"); var producer = (FtpProducer)prodEp.CreateProducer(); await producer.Start(); for (int i = 0; i < fileCount; i++) { var ex = new Exchange(new Message($"content-{i}")); ex.In.Headers[FtpHeaders.FileName] = $"file-{i}.txt"; await producer.Process(ex); } await producer.Stop(); var consEp = CreateEndpoint(remotePath, "noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var allDone = new TaskCompletionSource(); var counter = 0; var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); if (Interlocked.Increment(ref counter) >= fileCount) allDone.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)consEp.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(allDone.Task, Task.Delay(15_000)); await consumer.Stop(); received.Count.Should().BeGreaterThanOrEqualTo(fileCount); using var rawClient = await CreateRawClientAsync(); await CleanupDirAsync(rawClient, $"/{remotePath}"); } [Fact] public async Task Producer_NullBody_WithAllowNullBody_UploadsEmptyFile() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&allowNullBody=true"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message { Body = null }); exchange.In.Headers[FtpHeaders.FileName] = "empty.txt"; await producer.Process(exchange); await producer.Stop(); using var client = await CreateRawClientAsync(); var filePath = $"/{remotePath}/empty.txt"; (await client.FileExists(filePath)).Should().BeTrue(); using var ms = new MemoryStream(); await client.DownloadStream(ms, filePath); ms.ToArray().Length.Should().Be(0); await CleanupDirAsync(client, $"/{remotePath}"); } [Fact] public async Task Producer_NullBody_WithoutAllowNullBody_Throws() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&allowNullBody=false"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var exchange = new Exchange(new Message { Body = null }); exchange.In.Headers[FtpHeaders.FileName] = "null.txt"; var act = () => producer.Process(exchange); await act.Should().ThrowAsync().WithMessage("*AllowNullBody*"); await producer.Stop(); } [Fact] public async Task Producer_FileExistMove_BacksUpExisting() { var dir = UniqueDir(); var remotePath = $"{dir}"; var ep = CreateEndpoint(remotePath, "autoCreate=true&fileExist=Move&moveExistingFileStrategy=Backup"); var producer = (FtpProducer)ep.CreateProducer(); await producer.Start(); var ex1 = new Exchange(new Message("v1")); ex1.In.Headers[FtpHeaders.FileName] = "versioned.txt"; await producer.Process(ex1); var ex2 = new Exchange(new Message("v2")); ex2.In.Headers[FtpHeaders.FileName] = "versioned.txt"; await producer.Process(ex2); await producer.Stop(); using var client = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; (await client.FileExists($"{fullDir}/versioned.txt")).Should().BeTrue(); var content = await ReadFileAsync(client, $"{fullDir}/versioned.txt"); content.Should().Be("v2"); var items = await client.GetListing(fullDir); items.Where(f => f.Name.StartsWith("versioned.txt.bak")).Should().HaveCount(1); await CleanupDirAsync(client, fullDir); } [Fact] public async Task Consumer_PreMove_MovesBeforeProcessing() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/source.txt", "pre-move data"); var ep = CreateEndpoint(remotePath, "preMove=.inprogress&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); (await rawClient.FileExists($"{fullDir}/source.txt")).Should().BeFalse(); (await rawClient.FileExists($"{fullDir}/.inprogress/source.txt")).Should().BeTrue(); await CleanupDirAsync(rawClient, fullDir); } // ───── StreamBody Tests ───── [Fact] public async Task Consumer_StreamBody_ReceivesStream() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/streamed.txt", "stream content"); var ep = CreateEndpoint(remotePath, "streamBody=true&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); var rx = received.First(); rx.In.Body.Should().BeAssignableTo(); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_StreamBody_DataCorrect() { var dir = UniqueDir(); var remotePath = $"{dir}"; var expectedContent = "hello from ftp stream"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/readable.txt", expectedContent); var ep = CreateEndpoint(remotePath, "streamBody=true&noop=true&delay=500&initialDelay=100"); string? readContent = null; var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(async ci => { var exchange = ci.ArgAt(0); var stream = (Stream)exchange.In.Body!; using var reader = new StreamReader(stream, Encoding.UTF8, leaveOpen: true); readContent = await reader.ReadToEndAsync(); tcs.TrySetResult(); }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); readContent.Should().Be(expectedContent); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_StreamBody_HeadersPopulated() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/meta.txt", "headers test"); var ep = CreateEndpoint(remotePath, "streamBody=true&noop=true&delay=500&initialDelay=100"); var received = new ConcurrentBag(); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { received.Add(ci.ArgAt(0)); tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); received.Should().HaveCount(1); var rx = received.First(); rx.In.Headers[FtpHeaders.FileName].Should().Be("meta.txt"); rx.In.Headers[FtpHeaders.FileNameOnly].Should().Be("meta"); rx.In.Headers[FtpHeaders.FileExtension].Should().Be(".txt"); rx.In.Headers[FtpHeaders.Host].Should().Be(Host); rx.In.Headers[FtpHeaders.Port].Should().Be(Port); rx.In.Headers[FtpHeaders.Username].Should().Be(Username); ((long)rx.In.Headers[FtpHeaders.FileLength]!).Should().BeGreaterThan(0); await CleanupDirAsync(rawClient, fullDir); } [Fact] public async Task Consumer_StreamBody_DeleteAfterRead() { var dir = UniqueDir(); var remotePath = $"{dir}"; using var rawClient = await CreateRawClientAsync(); var fullDir = $"/{remotePath}"; await rawClient.CreateDirectory(fullDir, true); await SeedFileAsync(rawClient, $"{fullDir}/deletable.txt", "delete after stream"); var ep = CreateEndpoint(remotePath, "streamBody=true&delete=true&delay=500&initialDelay=100"); var tcs = new TaskCompletionSource(); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { tcs.TrySetResult(); return Task.CompletedTask; }); var consumer = (FtpConsumer)ep.CreateConsumer(processor); await consumer.Start(); await Task.WhenAny(tcs.Task, Task.Delay(15_000)); await consumer.Stop(); (await rawClient.FileExists($"{fullDir}/deletable.txt")).Should().BeFalse(); await CleanupDirAsync(rawClient, fullDir); } // ── The options sweep: transferType ────────────────────────────────────── [Fact] public async Task TransferTypeAscii_ReachesTheClientConfig() { // The option was declared, documented ("Binary (raw bytes, default) or Ascii") and read // by nothing: FluentFTP stayed on its own default for both directions. var options = new FtpEndpointOptions { Host = Host, Port = Port, Username = Username, Password = Password, TransferType = FtpTransferType.Ascii, }; var ops = new FtpFileOperations(options); await ops.ConnectAsync(); try { ops.Client!.Config.UploadDataType.Should().Be(FtpDataType.ASCII, "transferType=Ascii must reach the client, not be a dead option"); ops.Client.Config.DownloadDataType.Should().Be(FtpDataType.ASCII); } finally { await ops.DisconnectAsync(); } } } Path: redb-route/tests/redb.Route.Tests.Ftp/FtpTraceTests.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.Ftp/FtpTraceTests.cs ---- using System.Diagnostics; using System.Text; using FluentFTP; using redb.Route.Abstractions; using redb.Route.Configuration; using redb.Route.Core; using redb.Route.Ftp; using redb.Route.Telemetry; using redb.Route.Tests.Telemetry; namespace redb.Route.Tests.Ftp; /// /// A polled remote file carries no trace context: the consumer opens a root span per routed file, never a child of the /// activity the poll loop inherited from whoever started it, and none for an empty poll. A failed route marks it red. /// EnableTelemetry=false opens none. Each test polls a directory of its own and reads only the spans of that /// endpoint. Expects FTP at localhost:21 (testuser/secret). /// [Trait("Category", "Integration")] public sealed class FtpTraceTests : IAsyncLifetime { private const string Host = "localhost"; private const int Port = 21; private const string Username = "testuser"; private const string Password = "secret"; private static readonly TimeSpan Wait = TimeSpan.FromSeconds(15); private readonly string _dir = $"trace-{Guid.NewGuid():N}"; private AsyncFtpClient _client = null!; public async Task InitializeAsync() { _client = new AsyncFtpClient(Host, Username, Password, Port); await _client.Connect(); await _client.CreateDirectory($"/{_dir}"); } public async Task DisposeAsync() { if (await _client.DirectoryExists($"/{_dir}")) { foreach (var item in await _client.GetListing($"/{_dir}")) if (item.Type == FtpObjectType.File) await _client.DeleteFile(item.FullName); await _client.DeleteDirectory($"/{_dir}"); } _client.Dispose(); } private string Uri => $"ftp:///{_dir}?host={Host}&port={Port}&username={Username}&password={Password}" + "&delay=200&initialDelay=10&delete=true"; private RouteTelemetryProbe Spans() => new(a => RouteTelemetryProbe.Tag(a, RouteTelemetryProbe.EndpointTag)?.Contains(_dir, StringComparison.Ordinal) == true); private async Task Seed(string name) { using var content = new MemoryStream(Encoding.UTF8.GetBytes("payload")); await _client.UploadStream(content, $"/{_dir}/{name}", FtpRemoteExists.Overwrite, true); } private async Task StartConsumer(Action step, bool telemetry = true) { var ctx = new RouteContext(options: new RouteEngineOptions { EnableTelemetry = telemetry }); ctx.AddComponent(new FtpComponent()); ctx.AddRoutes(r => r.From(Uri).Process(step)); using (new Activity("host startup").SetIdFormat(ActivityIdFormat.W3C).Start()) await ctx.Start(); return ctx; } private static async Task Until(Func done) { var deadline = DateTime.UtcNow + Wait; while (!done() && DateTime.UtcNow < deadline) await Task.Delay(100); } [Fact] public async Task Each_file_opens_a_root_span_even_under_an_ambient_activity() { await Seed("a.txt"); await Seed("b.txt"); using var probe = Spans(); await using (await StartConsumer(_ => { })) await Until(() => probe.Activities.Count(a => a.Kind == ActivityKind.Consumer) >= 2); var receives = probe.Activities.Where(a => a.Kind == ActivityKind.Consumer).ToList(); receives.Should().HaveCount(2, "one span per routed file"); receives.Should().OnlyContain(a => a.ParentSpanId == default(ActivitySpanId), "a file carries no context, so its span starts a trace rather than joining the host's"); receives[0].GetTagItem("redb.system").Should().Be("ftp"); } [Fact] public async Task An_empty_poll_opens_no_span() { using var probe = Spans(); await using (await StartConsumer(_ => { })) await Task.Delay(1500); // several polls of an empty directory probe.Activities.Should().BeEmpty(); } [Fact] public async Task A_failed_route_marks_the_span_red() { await Seed("fail.txt"); using var probe = Spans(); await using (await StartConsumer(_ => throw new InvalidOperationException("route failed"))) await Until(() => probe.Activities.Any(a => a.Kind == ActivityKind.Consumer)); probe.Activities.Where(a => a.Kind == ActivityKind.Consumer).Should().NotBeEmpty() .And.OnlyContain(a => a.Status == ActivityStatusCode.Error); } [Fact] public async Task Tracing_off_opens_no_span() { await Seed("off.txt"); using var probe = Spans(); var routed = new TaskCompletionSource(); await using (await StartConsumer(_ => routed.TrySetResult(), telemetry: false)) (await Task.WhenAny(routed.Task, Task.Delay(Wait))).Should().Be(routed.Task); probe.Activities.Should().BeEmpty(); } } Path: redb-route/tests/redb.Route.Tests.Ftp/ServiceCollectionExtensionsTests.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.Ftp/ServiceCollectionExtensionsTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Extensions; using redb.Route.Ftp; namespace redb.Route.Tests.Ftp; public sealed class ServiceCollectionExtensionsTests { [Fact] public void AddRedbRouteFtp_RegistersFtpComponent() { var services = new ServiceCollection(); services.AddRedbRouteFtp(); var descriptors = services.Where(d => d.ServiceType == typeof(FtpComponent)).ToList(); descriptors.Should().HaveCount(1); descriptors[0].Lifetime.Should().Be(ServiceLifetime.Singleton); } [Fact] public async Task AddRedbRouteFtp_ConfiguratorRegistersComponentInContext() { var services = new ServiceCollection(); services.AddRedbRouteFtp(); services.Where(d => d.ServiceType == typeof(IRouteContextConfigurator)) .Should().ContainSingle() .Which.Lifetime.Should().Be(ServiceLifetime.Singleton); await using var sp = services.BuildServiceProvider(); await using var context = new RouteContext(); foreach (var configurator in sp.GetServices()) configurator.Configure(context); context.HasComponent("ftp").Should().BeTrue(); } [Fact] public void AddRedbRouteFtp_ReturnsServices() { var services = new ServiceCollection(); var result = services.AddRedbRouteFtp(); result.Should().BeSameAs(services); } [Fact] public void AddRedbRouteFtp_ResolvesComponent() { var services = new ServiceCollection(); services.AddRedbRouteFtp(); var routeContext = Substitute.For(); services.AddSingleton(routeContext); var provider = services.BuildServiceProvider(); var component = provider.GetRequiredService(); component.Should().NotBeNull(); component.Scheme.Should().Be("ftp"); } [Fact] public void AddRedbRouteFtp_IdempotentMultipleCalls() { var services = new ServiceCollection(); services.AddRedbRouteFtp(); services.AddRedbRouteFtp(); var descriptors = services.Where(d => d.ServiceType == typeof(FtpComponent)).ToList(); descriptors.Should().HaveCountGreaterThanOrEqualTo(1); } } Path: redb-route/tests/redb.Route.Tests.Ftp/redb.Route.Tests.Ftp.csproj 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.Ftp/redb.Route.Tests.Ftp.csproj ----