33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using System.Text.Json;
|
|
using WxAgent.Core;
|
|
using WxAgent.Service;
|
|
using Xunit;
|
|
|
|
namespace WxAgent.Service.Tests;
|
|
|
|
public sealed class ReadCoverageTests
|
|
{
|
|
[Fact]
|
|
public void PageSerializesCoverageWithoutChangingExistingPageShape()
|
|
{
|
|
var page = new Page<string>(["chat-a"], 20, 0, false, null)
|
|
{
|
|
Coverage = new ReadCoverage(
|
|
ReadCoverageStates.Partial,
|
|
"uia-session-list",
|
|
ObservedCount: 1,
|
|
AuthorizedScopeCount: 2,
|
|
MatchedScopeCount: 1,
|
|
DateTimeOffset.Parse("2026-09-21T10:00:00Z"),
|
|
"ScopeIdentityNotObserved")
|
|
};
|
|
|
|
using var document = JsonDocument.Parse(JsonSerializer.Serialize(page, RemoteJson.Options));
|
|
var root = document.RootElement;
|
|
Assert.Equal(1, root.GetProperty("items").GetArrayLength());
|
|
Assert.Equal("partial", root.GetProperty("coverage").GetProperty("state").GetString());
|
|
Assert.Equal(2, root.GetProperty("coverage").GetProperty("authorizedScopeCount").GetInt32());
|
|
Assert.Equal("ScopeIdentityNotObserved", root.GetProperty("coverage").GetProperty("errorCode").GetString());
|
|
}
|
|
}
|