- Add Microsoft.Extensions.Logging + Serilog to NatsServer and NatsClient - Convert all test assertions from xUnit Assert to Shouldly - Add NSubstitute package for future mocking needs - Introduce Central Package Management via Directory.Packages.props - Add documentation_rules.md with style guide, generation/update rules, component map - Generate 10 documentation files across 5 component folders (GettingStarted, Protocol, Subscriptions, Server, Configuration/Operations) - Update CLAUDE.md with logging, testing, porting, agent model, CPM, and documentation guidance
58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using NATS.Server.Subscriptions;
|
|
|
|
namespace NATS.Server.Tests;
|
|
|
|
public class SubjectMatchTests
|
|
{
|
|
[Theory]
|
|
[InlineData("foo", true)]
|
|
[InlineData("foo.bar", true)]
|
|
[InlineData("foo.bar.baz", true)]
|
|
[InlineData("foo.*", true)]
|
|
[InlineData("foo.>", true)]
|
|
[InlineData(">", true)]
|
|
[InlineData("*", true)]
|
|
[InlineData("*.bar", true)]
|
|
[InlineData("foo.*.baz", true)]
|
|
[InlineData("", false)]
|
|
[InlineData("foo.", false)]
|
|
[InlineData(".foo", false)]
|
|
[InlineData("foo..bar", false)]
|
|
[InlineData("foo.>.bar", false)] // > must be last token
|
|
[InlineData("foo bar", false)] // no spaces
|
|
[InlineData("foo\tbar", false)] // no tabs
|
|
public void IsValidSubject(string subject, bool expected)
|
|
{
|
|
SubjectMatch.IsValidSubject(subject).ShouldBe(expected);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("foo", true)]
|
|
[InlineData("foo.bar.baz", true)]
|
|
[InlineData("foo.*", false)]
|
|
[InlineData("foo.>", false)]
|
|
[InlineData(">", false)]
|
|
[InlineData("*", false)]
|
|
public void IsValidPublishSubject(string subject, bool expected)
|
|
{
|
|
SubjectMatch.IsValidPublishSubject(subject).ShouldBe(expected);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("foo", "foo", true)]
|
|
[InlineData("foo", "bar", false)]
|
|
[InlineData("foo.bar", "foo.*", true)]
|
|
[InlineData("foo.bar", "*.bar", true)]
|
|
[InlineData("foo.bar", "*.*", true)]
|
|
[InlineData("foo.bar.baz", "foo.>", true)]
|
|
[InlineData("foo.bar.baz", ">", true)]
|
|
[InlineData("foo.bar", "foo.>", true)]
|
|
[InlineData("foo", "foo.>", false)]
|
|
[InlineData("foo.bar.baz", "foo.*", false)]
|
|
[InlineData("foo.bar", "foo.bar.>", false)]
|
|
public void MatchLiteral(string literal, string pattern, bool expected)
|
|
{
|
|
SubjectMatch.MatchLiteral(literal, pattern).ShouldBe(expected);
|
|
}
|
|
}
|