Fix process crash when testing Stderr (#1449)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
70442e9351
commit
2e7209c35a
1 changed files with 254 additions and 148 deletions
|
|
@ -9,16 +9,17 @@ namespace ModelContextProtocol.Tests.Configuration;
|
|||
public class McpServerBuilderExtensionsTransportsTests
|
||||
{
|
||||
[Fact]
|
||||
public void WithStdioServerTransport_Sets_Transport()
|
||||
public void WithStdioServerTransport_Registers_Transport()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddMcpServer().WithStdioServerTransport();
|
||||
|
||||
var transportServiceType = services.FirstOrDefault(s => s.ServiceType == typeof(ITransport));
|
||||
Assert.NotNull(transportServiceType);
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
Assert.IsType<StdioServerTransport>(serviceProvider.GetRequiredService<ITransport>());
|
||||
// Verify StdioServerTransport is registered for ITransport, but don't resolve it —
|
||||
// doing so opens Console.OpenStandardInput() which permanently blocks a thread pool
|
||||
// thread on the test host's stdin. StdioServerTransport should only be used in a
|
||||
// dedicated child process, not in-process.
|
||||
var transportDescriptor = services.FirstOrDefault(s => s.ServiceType == typeof(ITransport));
|
||||
Assert.NotNull(transportDescriptor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in a new issue