File tree 1 file changed +11
-1
lines changed
tests/ModelContextProtocol.AspNetCore.Tests
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -38,12 +38,22 @@ public async Task Allows_Customizing_Route()
38
38
Builder . Services . AddMcpServer ( ) . WithHttpTransport ( ) ;
39
39
await using var app = Builder . Build ( ) ;
40
40
41
- app . MapMcp ( "/mcp" ) ;
41
+ var pattern = "/mcp" ;
42
+
43
+ app . MapMcp ( pattern ) ;
42
44
43
45
await app . StartAsync ( TestContext . Current . CancellationToken ) ;
44
46
45
47
using var response = await HttpClient . GetAsync ( "http://localhost/mcp/sse" , HttpCompletionOption . ResponseHeadersRead , TestContext . Current . CancellationToken ) ;
46
48
response . EnsureSuccessStatusCode ( ) ;
49
+ using var sseStream = await response . Content . ReadAsStreamAsync ( TestContext . Current . CancellationToken ) ;
50
+ using var sseStreamReader = new StreamReader ( sseStream , System . Text . Encoding . UTF8 ) ;
51
+ var eventLine = await sseStreamReader . ReadLineAsync ( TestContext . Current . CancellationToken ) ;
52
+ var dataLine = await sseStreamReader . ReadLineAsync ( TestContext . Current . CancellationToken ) ;
53
+ Assert . NotNull ( eventLine ) ;
54
+ Assert . Equal ( "event: endpoint" , eventLine ) ;
55
+ Assert . NotNull ( dataLine ) ;
56
+ Assert . Equal ( $ "data: { pattern } /message", dataLine [ ..dataLine . IndexOf ( '?' ) ] ) ;
47
57
}
48
58
49
59
[ Theory ]
You can’t perform that action at this time.
0 commit comments