Add serialization roundtrip tests for all Protocol namespace types (#1289)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
392e47ea29
commit
4cef394ad5
1 changed files with 3222 additions and 475 deletions
|
|
@ -0,0 +1,46 @@
|
|||
using ModelContextProtocol.Protocol;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModelContextProtocol.Tests.Protocol;
|
||||
|
||||
public static class ListTasksResultTests
|
||||
{
|
||||
[Fact]
|
||||
public static void ListTasksResult_SerializationRoundTrip()
|
||||
{
|
||||
// Arrange
|
||||
var original = new ListTasksResult
|
||||
{
|
||||
Tasks =
|
||||
[
|
||||
new McpTask
|
||||
{
|
||||
TaskId = "task-1",
|
||||
Status = McpTaskStatus.Working,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
LastUpdatedAt = DateTimeOffset.UtcNow
|
||||
},
|
||||
new McpTask
|
||||
{
|
||||
TaskId = "task-2",
|
||||
Status = McpTaskStatus.Completed,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
LastUpdatedAt = DateTimeOffset.UtcNow
|
||||
}
|
||||
],
|
||||
NextCursor = "next-page-token"
|
||||
};
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(original, McpJsonUtilities.DefaultOptions);
|
||||
var deserialized = JsonSerializer.Deserialize<ListTasksResult>(json, McpJsonUtilities.DefaultOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(deserialized);
|
||||
Assert.NotNull(deserialized.Tasks);
|
||||
Assert.Equal(2, deserialized.Tasks.Length);
|
||||
Assert.Equal(original.Tasks[0].TaskId, deserialized.Tasks[0].TaskId);
|
||||
Assert.Equal(original.Tasks[1].TaskId, deserialized.Tasks[1].TaskId);
|
||||
Assert.Equal(original.NextCursor, deserialized.NextCursor);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue