Update to latest M.E.AI version (#401)
This commit is contained in:
parent
26c3622101
commit
61092e0266
3 changed files with 106 additions and 10 deletions
|
|
@ -60,7 +60,7 @@ public class McpServerPromptTests
|
|||
Assert.Contains("something", prompt.ProtocolPrompt.Arguments?.Select(a => a.Name) ?? []);
|
||||
Assert.DoesNotContain("actualMyService", prompt.ProtocolPrompt.Arguments?.Select(a => a.Name) ?? []);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(async () => await prompt.GetAsync(
|
||||
await Assert.ThrowsAnyAsync<ArgumentException>(async () => await prompt.GetAsync(
|
||||
new RequestContext<GetPromptRequestParams>(new Mock<IMcpServer>().Object),
|
||||
TestContext.Current.CancellationToken));
|
||||
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ public partial class McpServerResourceTests
|
|||
|
||||
Mock<IMcpServer> mockServer = new();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(async () => await resource.ReadAsync(
|
||||
await Assert.ThrowsAnyAsync<ArgumentException>(async () => await resource.ReadAsync(
|
||||
new RequestContext<ReadResourceRequestParams>(mockServer.Object) { Params = new() { Uri = "resource://Test" } },
|
||||
TestContext.Current.CancellationToken));
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,10 @@ public partial class McpServerToolTests
|
|||
[Fact]
|
||||
public async Task SupportsAsyncDisposingInstantiatedAsyncDisposableAndDisposableTargets()
|
||||
{
|
||||
ServiceCollection sc = new();
|
||||
sc.AddSingleton<MyService>();
|
||||
IServiceProvider services = sc.BuildServiceProvider();
|
||||
|
||||
McpServerToolCreateOptions options = new() { SerializerOptions = JsonContext2.Default.Options };
|
||||
McpServerTool tool1 = McpServerTool.Create(
|
||||
typeof(AsyncDisposableAndDisposableToolType).GetMethod(nameof(AsyncDisposableAndDisposableToolType.InstanceMethod))!,
|
||||
|
|
@ -163,7 +167,7 @@ public partial class McpServerToolTests
|
|||
options);
|
||||
|
||||
var result = await tool1.InvokeAsync(
|
||||
new RequestContext<CallToolRequestParams>(new Mock<IMcpServer>().Object),
|
||||
new RequestContext<CallToolRequestParams>(new Mock<IMcpServer>().Object) { Services = services },
|
||||
TestContext.Current.CancellationToken);
|
||||
Assert.Equal("""{"asyncDisposals":1,"disposals":0}""", result.Content[0].Text);
|
||||
}
|
||||
|
|
@ -428,6 +432,11 @@ public partial class McpServerToolTests
|
|||
|
||||
private class AsyncDisposableAndDisposableToolType : IAsyncDisposable, IDisposable
|
||||
{
|
||||
public AsyncDisposableAndDisposableToolType(MyService service)
|
||||
{
|
||||
Assert.NotNull(service);
|
||||
}
|
||||
|
||||
[JsonPropertyOrder(0)]
|
||||
public int AsyncDisposals { get; private set; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue