Use Kestrel for all in-memory HTTP tests (#225)
* Add route pattern parameter to MapMcp * Add configureOptionsAsync * Use Kestrel for all in-memory HTTP tests * Use ApplicationStopping token for SSE responses * Use RegisterNotificationHandler in MapMcp tests * Work around SocketsHttpHandler bug where it doesn't call DispseAsync on the stream returned by the ConnectCallback
This commit is contained in:
parent
848c9df433
commit
faf12b6a94
1 changed files with 631 additions and 642 deletions
19
tests/ModelContextProtocol.Tests/Server/MapMcpTests.cs
Normal file
19
tests/ModelContextProtocol.Tests/Server/MapMcpTests.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using ModelContextProtocol.Tests.Utils;
|
||||
|
||||
namespace ModelContextProtocol.Tests.Server;
|
||||
|
||||
public class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelInMemoryTest(testOutputHelper)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Allows_Customizing_Route()
|
||||
{
|
||||
await using var app = Builder.Build();
|
||||
app.MapMcp("/mcp");
|
||||
await app.StartAsync(TestContext.Current.CancellationToken);
|
||||
|
||||
using var httpClient = CreateHttpClient();
|
||||
using var response = await httpClient.GetAsync("http://localhost/mcp/sse", HttpCompletionOption.ResponseHeadersRead, TestContext.Current.CancellationToken);
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue