2
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Eis.Infrastructure.Administration;
|
||||
|
||||
namespace Eis.Infrastructure.Tests.Administration;
|
||||
|
||||
public sealed class AdminNoticeServiceTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("publicVisible")]
|
||||
[InlineData("visible")]
|
||||
public void TryReadPublicVisibility_AcceptsCurrentAndLegacyKeys(string key)
|
||||
{
|
||||
var body = new JsonObject { [key] = false };
|
||||
|
||||
var parsed = AdminNoticeService.TryReadPublicVisibility(body, out var visible);
|
||||
|
||||
Assert.True(parsed);
|
||||
Assert.False(visible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryReadPublicVisibility_RejectsMissingOrNonBooleanValue()
|
||||
{
|
||||
Assert.False(AdminNoticeService.TryReadPublicVisibility(new JsonObject(), out _));
|
||||
Assert.False(AdminNoticeService.TryReadPublicVisibility(
|
||||
new JsonObject { ["publicVisible"] = "false" },
|
||||
out _));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user