30 lines
877 B
C#
30 lines
877 B
C#
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 _));
|
|
}
|
|
}
|