@@ -11,29 +11,24 @@ namespace ModelContextProtocol.Tests.Client;
11
11
12
12
public class McpClientFactoryTests
13
13
{
14
- private readonly McpClientOptions _defaultOptions = new ( )
15
- {
16
- ClientInfo = new ( ) { Name = "TestClient" , Version = "1.0.0" }
17
- } ;
18
-
19
14
[ Fact ]
20
15
public async Task CreateAsync_WithInvalidArgs_Throws ( )
21
16
{
22
- await Assert . ThrowsAsync < ArgumentNullException > ( "serverConfig" , ( ) => McpClientFactory . CreateAsync ( ( McpServerConfig ) null ! , _defaultOptions , cancellationToken : TestContext . Current . CancellationToken ) ) ;
17
+ await Assert . ThrowsAsync < ArgumentNullException > ( "serverConfig" , ( ) => McpClientFactory . CreateAsync ( ( McpServerConfig ) null ! , cancellationToken : TestContext . Current . CancellationToken ) ) ;
23
18
24
19
await Assert . ThrowsAsync < ArgumentException > ( "serverConfig" , ( ) => McpClientFactory . CreateAsync ( new McpServerConfig ( )
25
20
{
26
21
Name = "name" ,
27
22
Id = "id" ,
28
23
TransportType = "somethingunsupported" ,
29
- } , _defaultOptions , cancellationToken : TestContext . Current . CancellationToken ) ) ;
24
+ } , cancellationToken : TestContext . Current . CancellationToken ) ) ;
30
25
31
26
await Assert . ThrowsAsync < InvalidOperationException > ( ( ) => McpClientFactory . CreateAsync ( new McpServerConfig ( )
32
27
{
33
28
Name = "name" ,
34
29
Id = "id" ,
35
30
TransportType = TransportTypes . StdIo ,
36
- } , _defaultOptions , ( _ , __ ) => null ! , cancellationToken : TestContext . Current . CancellationToken ) ) ;
31
+ } , createTransportFunc : ( _ , __ ) => null ! , cancellationToken : TestContext . Current . CancellationToken ) ) ;
37
32
}
38
33
39
34
[ Fact ]
@@ -78,8 +73,7 @@ public async Task CreateAsync_WithValidStdioConfig_CreatesNewClient()
78
73
// Act
79
74
await using var client = await McpClientFactory . CreateAsync (
80
75
serverConfig ,
81
- _defaultOptions ,
82
- ( _ , __ ) => new NopTransport ( ) ,
76
+ createTransportFunc : ( _ , __ ) => new NopTransport ( ) ,
83
77
cancellationToken : TestContext . Current . CancellationToken ) ;
84
78
85
79
// Assert
@@ -102,8 +96,7 @@ public async Task CreateAsync_WithNoTransportOptions_CreatesNewClient()
102
96
// Act
103
97
await using var client = await McpClientFactory . CreateAsync (
104
98
serverConfig ,
105
- _defaultOptions ,
106
- ( _ , __ ) => new NopTransport ( ) ,
99
+ createTransportFunc : ( _ , __ ) => new NopTransport ( ) ,
107
100
cancellationToken : TestContext . Current . CancellationToken ) ;
108
101
109
102
// Assert
@@ -126,8 +119,7 @@ public async Task CreateAsync_WithValidSseConfig_CreatesNewClient()
126
119
// Act
127
120
await using var client = await McpClientFactory . CreateAsync (
128
121
serverConfig ,
129
- _defaultOptions ,
130
- ( _ , __ ) => new NopTransport ( ) ,
122
+ createTransportFunc : ( _ , __ ) => new NopTransport ( ) ,
131
123
cancellationToken : TestContext . Current . CancellationToken ) ;
132
124
133
125
// Assert
@@ -157,8 +149,7 @@ public async Task CreateAsync_WithSse_CreatesCorrectTransportOptions()
157
149
// Act
158
150
await using var client = await McpClientFactory . CreateAsync (
159
151
serverConfig ,
160
- _defaultOptions ,
161
- ( _ , __ ) => new NopTransport ( ) ,
152
+ createTransportFunc : ( _ , __ ) => new NopTransport ( ) ,
162
153
cancellationToken : TestContext . Current . CancellationToken ) ;
163
154
164
155
// Assert
@@ -186,7 +177,7 @@ public async Task McpFactory_WithInvalidTransportOptions_ThrowsFormatException(s
186
177
} ;
187
178
188
179
// act & assert
189
- await Assert . ThrowsAsync < ArgumentException > ( ( ) => McpClientFactory . CreateAsync ( config , _defaultOptions , cancellationToken : TestContext . Current . CancellationToken ) ) ;
180
+ await Assert . ThrowsAsync < ArgumentException > ( ( ) => McpClientFactory . CreateAsync ( config , cancellationToken : TestContext . Current . CancellationToken ) ) ;
190
181
}
191
182
192
183
[ Theory ]
@@ -205,11 +196,6 @@ public async Task CreateAsync_WithCapabilitiesOptions(Type transportType)
205
196
206
197
var clientOptions = new McpClientOptions
207
198
{
208
- ClientInfo = new Implementation
209
- {
210
- Name = "TestClient" ,
211
- Version = "1.0.0.0"
212
- } ,
213
199
Capabilities = new ClientCapabilities
214
200
{
215
201
Sampling = new SamplingCapability
0 commit comments