Ensure all test client instances are cleaned up (#3)
This commit is contained in:
parent
fd358b437d
commit
555933a06e
3 changed files with 10 additions and 12 deletions
|
|
@ -65,7 +65,7 @@ public class McpClientFactoryTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(
|
||||
await using var client = await McpClientFactory.CreateAsync(
|
||||
serverConfig,
|
||||
_defaultOptions,
|
||||
(_, __) => new NopTransport());
|
||||
|
|
@ -88,7 +88,7 @@ public class McpClientFactoryTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(
|
||||
await using var client = await McpClientFactory.CreateAsync(
|
||||
serverConfig,
|
||||
_defaultOptions,
|
||||
(_, __) => new NopTransport());
|
||||
|
|
@ -111,7 +111,7 @@ public class McpClientFactoryTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(
|
||||
await using var client = await McpClientFactory.CreateAsync(
|
||||
serverConfig,
|
||||
_defaultOptions,
|
||||
(_, __) => new NopTransport());
|
||||
|
|
@ -141,7 +141,7 @@ public class McpClientFactoryTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(
|
||||
await using var client = await McpClientFactory.CreateAsync(
|
||||
serverConfig,
|
||||
_defaultOptions,
|
||||
(_, __) => new NopTransport());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class SseIntegrationTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
await using var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
|
||||
// Wait for SSE connection to be established
|
||||
await server.WaitForConnectionAsync(TimeSpan.FromSeconds(10));
|
||||
|
|
@ -82,7 +82,7 @@ public class SseIntegrationTests
|
|||
};
|
||||
|
||||
// Create client and run tests
|
||||
var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
await using var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
var tools = await client.ListToolsAsync().ToListAsync();
|
||||
|
||||
// assert
|
||||
|
|
@ -147,7 +147,7 @@ public class SseIntegrationTests
|
|||
},
|
||||
};
|
||||
|
||||
var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
await using var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
|
||||
// Call the server's sampleLLM tool which should trigger our sampling handler
|
||||
var result = await client.CallToolAsync(
|
||||
|
|
@ -194,7 +194,7 @@ public class SseIntegrationTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
await using var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
|
||||
// Wait for SSE connection to be established
|
||||
await server.WaitForConnectionAsync(TimeSpan.FromSeconds(10));
|
||||
|
|
@ -233,7 +233,7 @@ public class SseIntegrationTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
await using var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
|
||||
// Wait for SSE connection to be established
|
||||
await server.WaitForConnectionAsync(TimeSpan.FromSeconds(10));
|
||||
|
|
@ -282,7 +282,7 @@ public class SseIntegrationTests
|
|||
};
|
||||
|
||||
// Act
|
||||
var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
await using var client = await McpClientFactory.CreateAsync(defaultConfig, defaultOptions, loggerFactory: loggerFactory);
|
||||
var mcpClient = (McpClient)client;
|
||||
var transport = (SseClientTransport)mcpClient.Transport;
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,6 @@ public class SseServerIntegrationTestFixture : IDisposable
|
|||
{
|
||||
try
|
||||
{
|
||||
var client = McpClientFactory.CreateAsync(DefaultConfig, DefaultOptions, loggerFactory: LoggerFactory).GetAwaiter().GetResult();
|
||||
client.DisposeAsync().AsTask().Wait();
|
||||
LoggerFactory?.Dispose();
|
||||
}
|
||||
finally
|
||||
|
|
|
|||
Loading…
Reference in a new issue