Skip to content

Commit f9d5ea4

Browse files
committed
Add asserts to test
1 parent f42e729 commit f9d5ea4

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/ModelContextProtocol.Tests/Transport/StdioClientTransportTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ModelContextProtocol.Client;
22
using ModelContextProtocol.Tests.Utils;
33
using System.Runtime.InteropServices;
4+
using System.Text;
45

56
namespace ModelContextProtocol.Tests.Transport;
67

@@ -25,7 +26,16 @@ public async Task CreateAsync_ValidProcessInvalidServer_StdErrCallbackInvoked()
2526
string id = Guid.NewGuid().ToString("N");
2627

2728
int count = 0;
28-
Action<string> stdErrCallback = line => Interlocked.Increment(ref count);
29+
StringBuilder sb = new();
30+
Action<string> stdErrCallback = line =>
31+
{
32+
Assert.NotNull(line);
33+
lock (sb)
34+
{
35+
sb.AppendLine(line);
36+
count++;
37+
}
38+
};
2939

3040
StdioClientTransport transport = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
3141
new(new() { Command = "cmd", Arguments = ["/C", $"echo \"{id}\" >&2"], StandardErrorLines = stdErrCallback }, LoggerFactory) :
@@ -34,5 +44,6 @@ public async Task CreateAsync_ValidProcessInvalidServer_StdErrCallbackInvoked()
3444
await Assert.ThrowsAsync<IOException>(() => McpClientFactory.CreateAsync(transport, loggerFactory: LoggerFactory, cancellationToken: TestContext.Current.CancellationToken));
3545

3646
Assert.InRange(count, 1, int.MaxValue);
47+
Assert.Contains(id, sb.ToString());
3748
}
3849
}

0 commit comments

Comments
 (0)