csharp-sdk/tests/ModelContextProtocol.Tests/Transport/StdioClientTransportTests.cs
Stephen Toub 106ab8064f
Clean up namespaces (#410)
No meaningful code changes, just lots of namespace shuffling to have fewer namespaces and to put things in better namespaces.
2025-05-14 14:50:26 -04:00

20 lines
767 B
C#

using ModelContextProtocol.Client;
using System.Runtime.InteropServices;
namespace ModelContextProtocol.Tests.Transport;
public class StdioClientTransportTests
{
[Fact]
public async Task CreateAsync_ValidProcessInvalidServer_Throws()
{
string id = Guid.NewGuid().ToString("N");
StdioClientTransport transport = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
new(new() { Command = "cmd", Arguments = ["/C", $"echo \"{id}\" >&2"] }) :
new(new() { Command = "ls", Arguments = [id] });
IOException e = await Assert.ThrowsAsync<IOException>(() => McpClientFactory.CreateAsync(transport, cancellationToken: TestContext.Current.CancellationToken));
Assert.Contains(id, e.ToString());
}
}