Path: redb-route/tests/redb.Route.Tests/Core/UriMaskValidateTests.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/UriMaskValidateTests.cs
----
using redb.Route.Core;
namespace redb.Route.Tests.Core;
/// Code review 2026-09-01: a mask is validated where it is declared, so an invalid regex names itself instead of dropping a route at compile.
public class UriMaskValidateTests
{
[Fact]
public void InvalidRegex_IsReportedAsSuch()
{
var act = () => UriMask.Validate("regex:[", "mask");
act.Should().Throw().WithMessage("*regular expression*").And.ParamName.Should().Be("mask");
}
[Theory]
[InlineData("")]
[InlineData(" ")]
[InlineData(null)]
public void BlankMask_IsRefused(string? pattern)
{
var act = () => UriMask.Validate(pattern);
act.Should().Throw();
}
[Theory]
[InlineData("kafka://*")]
[InlineData("regex:^kafka:.*$")]
[InlineData("X-Internal-*")]
public void UsableMasks_Pass(string pattern)
{
var act = () => UriMask.Validate(pattern);
act.Should().NotThrow();
}
}