test(cluster): HOCON parses, role parser truth table
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Cluster.Tests;
|
||||
|
||||
public sealed class RoleParserTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void Empty_input_yields_empty_array(string? raw)
|
||||
{
|
||||
RoleParser.Parse(raw).ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Single_role_admin()
|
||||
{
|
||||
RoleParser.Parse("admin").ShouldBe(new[] { "admin" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Two_roles_csv()
|
||||
{
|
||||
RoleParser.Parse("admin,driver").ShouldBe(new[] { "admin", "driver" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Whitespace_tolerant()
|
||||
{
|
||||
RoleParser.Parse(" admin , driver ").ShouldBe(new[] { "admin", "driver" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Case_insensitive_normalizes_to_lower()
|
||||
{
|
||||
RoleParser.Parse("ADMIN,Driver").ShouldBe(new[] { "admin", "driver" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Duplicate_roles_deduped()
|
||||
{
|
||||
RoleParser.Parse("admin,admin,driver").ShouldBe(new[] { "admin", "driver" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Unknown_role_throws()
|
||||
{
|
||||
Should.Throw<ArgumentException>(() => RoleParser.Parse("admin,master"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user