Path: redb-route/redb.Route.TestKit/MockUri.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/redb.Route.TestKit/MockUri.cs
----
namespace redb.Route.TestKit;
///
/// Maps an endpoint URI to the mock:// URI that stands in for it under
/// , the same way Apache Camel names its mocks
/// (mock:kafka:orders): the query string is dropped and scheme://path collapses to
/// scheme:path, so kafka://orders-vip?acks=all becomes mock://kafka:orders-vip.
///
public static class MockUri
{
/// Returns the mock:// URI standing in for ; a mock:// URI is returned unchanged.
public static string For(string endpointUri)
{
ArgumentException.ThrowIfNullOrWhiteSpace(endpointUri);
if (endpointUri.StartsWith("mock://", StringComparison.OrdinalIgnoreCase) ||
endpointUri.StartsWith("mock:", StringComparison.OrdinalIgnoreCase) && !endpointUri.Contains("://", StringComparison.Ordinal))
return endpointUri;
var queryIndex = endpointUri.IndexOf('?');
var withoutQuery = queryIndex >= 0 ? endpointUri[..queryIndex] : endpointUri;
return "mock://" + withoutQuery.Replace("://", ":", StringComparison.Ordinal);
}
}