FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix two minor test regressions from rebase · modelcontextprotocol/csharp-sdk@f3f6843 · GitHub

Repository navigation

Commit f3f6843

Browse files
andcommitted
Fix two minor test regressions from rebase
- RawStreamConformanceTests.cs: wrap in #if !NET472 to avoid ReadLineAsync(CancellationToken) overload missing on .NET Framework. - HttpMcpServerBuilderExtensionsTests: IdleTrackingBackgroundService_StartsTimer_WhenStateful needs explicit Stateless=false after the default flipped to true in commit 8904958. - HttpHeaderConformanceTests: two tests used the old DRAFT-2026-v1 wire-version string which the server now rejects; updated to 2026-07-28. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fd19c7d commit f3f6843

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎tests/ModelContextProtocol.AspNetCore.Tests/HttpHeaderConformanceTests.cs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public async Task Server_AcceptsUnionIntegerCanonicalForm()
122122

123123
using var request = new HttpRequestMessage(HttpMethod.Post, "");
124124
request.Content = new StringContent(callJson, Encoding.UTF8, "application/json");
125-
request.Headers.Add("MCP-Protocol-Version", "DRAFT-2026-v1");
125+
request.Headers.Add("MCP-Protocol-Version", "2026-07-28");
126126
request.Headers.Add("Mcp-Method", "tools/call");
127127
request.Headers.Add("Mcp-Name", "union_test");
128128
request.Headers.Add("Mcp-Param-Priority", "42");
@@ -141,7 +141,7 @@ public async Task Server_RejectsUnionIntegerOutsideSafeRange()
141141

142142
using var request = new HttpRequestMessage(HttpMethod.Post, "");
143143
request.Content = new StringContent(callJson, Encoding.UTF8, "application/json");
144-
request.Headers.Add("MCP-Protocol-Version", "DRAFT-2026-v1");
144+
request.Headers.Add("MCP-Protocol-Version", "2026-07-28");
145145
request.Headers.Add("Mcp-Method", "tools/call");
146146
request.Headers.Add("Mcp-Name", "union_test");
147147
request.Headers.Add("Mcp-Param-Priority", "9007199254740993");
@@ -161,7 +161,7 @@ public async Task Server_AcceptsExponentBodyMatchingDecimalHeader()
161161

162162
using var request = new HttpRequestMessage(HttpMethod.Post, "");
163163
request.Content = new StringContent(callJson, Encoding.UTF8, "application/json");
164-
request.Headers.Add("MCP-Protocol-Version", "DRAFT-2026-v1");
164+
request.Headers.Add("MCP-Protocol-Version", "2026-07-28");
165165
request.Headers.Add("Mcp-Method", "tools/call");
166166
request.Headers.Add("Mcp-Name", "header_test");
167167
request.Headers.Add("Mcp-Param-Region", "test");
@@ -334,7 +334,7 @@ public async Task Server_RejectsIntegerOutsideSafeRange(string outOfRangeValue)
334334

335335
using var request = new HttpRequestMessage(HttpMethod.Post, "");
336336
request.Content = new StringContent(callJson, Encoding.UTF8, "application/json");
337-
request.Headers.Add("MCP-Protocol-Version", "DRAFT-2026-v1");
337+
request.Headers.Add("MCP-Protocol-Version", "2026-07-28");
338338
request.Headers.Add("Mcp-Method", "tools/call");
339339
request.Headers.Add("Mcp-Name", "header_test");
340340
request.Headers.Add("Mcp-Param-Region", "test");
@@ -391,7 +391,7 @@ public async Task Server_RejectsNonIntegerValue_EvenWhenHeaderAndBodyMatch(strin
391391

392392
using var request = new HttpRequestMessage(HttpMethod.Post, "");
393393
request.Content = new StringContent(callJson, Encoding.UTF8, "application/json");
394-
request.Headers.Add("MCP-Protocol-Version", "DRAFT-2026-v1");
394+
request.Headers.Add("MCP-Protocol-Version", "2026-07-28");
395395
request.Headers.Add("Mcp-Method", "tools/call");
396396
request.Headers.Add("Mcp-Name", "header_test");
397397
request.Headers.Add("Mcp-Param-Region", "test");
@@ -620,3 +620,4 @@ private string CallTool(string toolName, string arguments = "{}")
620620

621621
#endregion
622622
}
623+

‎tests/ModelContextProtocol.AspNetCore.Tests/HttpMcpServerBuilderExtensionsTests.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public async Task IdleTrackingBackgroundService_StartsTimer_WhenStateful()
211211
{
212212
Builder.Services
213213
.AddMcpServer()
214-
.WithHttpTransport();
214+
.WithHttpTransport(options => options.Stateless = false);
215215

216216
using var app = Builder.Build();
217217

@@ -220,7 +220,7 @@ public async Task IdleTrackingBackgroundService_StartsTimer_WhenStateful()
220220

221221
await idleTrackingService.StartAsync(TestContext.Current.CancellationToken);
222222

223-
// In the default (stateful) mode the timer loop must start, so ExecuteTask should be set.
223+
// In stateful mode the timer loop must start, so ExecuteTask should be set.
224224
Assert.NotNull(idleTrackingService.ExecuteTask);
225225

226226
await idleTrackingService.StopAsync(TestContext.Current.CancellationToken);

‎tests/ModelContextProtocol.Tests/Server/RawStreamConformanceTests.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Extensions.DependencyInjection;
1+
#if !NET472
2+
using Microsoft.Extensions.DependencyInjection;
23
using Microsoft.Extensions.Logging;
34
using ModelContextProtocol.Protocol;
45
using ModelContextProtocol.Server;
@@ -71,7 +72,7 @@ public async ValueTask DisposeAsync()
7172

7273
private async Task<JsonNode> ReadAsync()
7374
{
74-
var line = await _reader.ReadLineAsync(_cts.Token);
75+
var line = await _reader.ReadLineAsync(_cts.Token).ConfigureAwait(false);
7576
Assert.NotNull(line);
7677
return JsonNode.Parse(line!)!;
7778
}
@@ -184,3 +185,4 @@ public async Task MixedSequence_Discover_Then_Initialize_Then_ToolsCall_AllSucce
184185
Assert.Equal("echo:after-init", call["result"]!["content"]![0]!["text"]!.GetValue<string>());
185186
}
186187
}
188+
#endif

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL