Add initial task extension conformance coverage (#1734)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7c99928c-a943-49f4-9a63-8b04a0e4d18b
This commit is contained in:
parent
f7c61fafdb
commit
83523b0a42
3 changed files with 463 additions and 43 deletions
|
|
@ -154,9 +154,10 @@ public class McpClientTaskMethodsTests : ClientServerTestBase
|
|||
{
|
||||
await client.CancelTaskAsync(taskId, ct);
|
||||
|
||||
// If cancel succeeded, verify the task is cancelled
|
||||
// Cancellation is eventually consistent. The task may complete before the cancellation
|
||||
// request wins the race, but the terminal-task cancellation acknowledgement is idempotent.
|
||||
var taskResult = await client.GetTaskAsync(taskId, ct);
|
||||
Assert.IsType<CancelledTaskResult>(taskResult);
|
||||
Assert.True(taskResult is CancelledTaskResult or CompletedTaskResult);
|
||||
}
|
||||
catch (McpProtocolException)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,6 +91,18 @@ public static class TaskSerializationTests
|
|||
|
||||
#endregion
|
||||
|
||||
[Theory]
|
||||
[InlineData(typeof(UpdateTaskResult))]
|
||||
[InlineData(typeof(CancelTaskResult))]
|
||||
public static void TaskAcknowledgement_SerializesExplicitCompleteResultType(Type resultType)
|
||||
{
|
||||
var result = (Result)Activator.CreateInstance(resultType)!;
|
||||
|
||||
var json = JsonSerializer.SerializeToNode(result, resultType, McpTasksJsonContext.Default.Options)!;
|
||||
|
||||
Assert.Equal("complete", (string)json["resultType"]!);
|
||||
}
|
||||
|
||||
#region GetTaskResult Subtypes
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -75,5 +75,28 @@ public class CustomRequestHandlerCollisionTests(ITestOutputHelper testOutputHelp
|
|||
await using var server = McpServer.Create(transport, options, LoggerFactory);
|
||||
Assert.NotNull(server);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CustomHandler_EmptyRoutingNameParameter_Throws()
|
||||
{
|
||||
await using var transport = new StreamServerTransport(Stream.Null, Stream.Null);
|
||||
var options = new McpServerOptions
|
||||
{
|
||||
RequestHandlers =
|
||||
[
|
||||
new McpServerRequestHandler
|
||||
{
|
||||
Method = "custom/method",
|
||||
RoutingNameParameter = " ",
|
||||
Handler = (request, cancellationToken) => new ValueTask<JsonNode?>((JsonNode?)null),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
var ex = Assert.Throws<InvalidOperationException>(
|
||||
() => McpServer.Create(transport, options, LoggerFactory));
|
||||
|
||||
Assert.Contains(nameof(McpServerRequestHandler.RoutingNameParameter), ex.Message);
|
||||
}
|
||||
#pragma warning restore MCPEXP002
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue