Fix process crash when testing Stderr (#1449)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Eric StJohn 2026-04-06 11:29:00 -07:00 • committed by GitHub
commit 2e7209c35a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]