Consolidate McpClientException/McpServerException into McpException (#209)
This commit is contained in:
parent
d1a3c201a4
commit
8fcdf95785
6 changed files with 163 additions and 197 deletions
|
|
@ -175,7 +175,7 @@ public class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIntegratio
|
|||
|
||||
// act
|
||||
await using var client = await _fixture.CreateClientAsync(clientId);
|
||||
await Assert.ThrowsAsync<McpClientException>(() =>
|
||||
await Assert.ThrowsAsync<McpException>(() =>
|
||||
client.GetPromptAsync("non_existent_prompt", null, cancellationToken: TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
|
|||
{
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
await Assert.ThrowsAsync<McpClientException>(async () => await client.GetPromptAsync(
|
||||
await Assert.ThrowsAsync<McpException>(async () => await client.GetPromptAsync(
|
||||
nameof(SimplePrompts.ThrowsException),
|
||||
cancellationToken: TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
|
|||
{
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
var e = await Assert.ThrowsAsync<McpClientException>(async () => await client.GetPromptAsync(
|
||||
var e = await Assert.ThrowsAsync<McpException>(async () => await client.GetPromptAsync(
|
||||
"NotRegisteredPrompt",
|
||||
cancellationToken: TestContext.Current.CancellationToken));
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
|
|||
{
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
var e = await Assert.ThrowsAsync<McpClientException>(async () => await client.GetPromptAsync(
|
||||
var e = await Assert.ThrowsAsync<McpException>(async () => await client.GetPromptAsync(
|
||||
nameof(SimplePrompts.ReturnsChatMessages),
|
||||
cancellationToken: TestContext.Current.CancellationToken));
|
||||
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ public class McpServerBuilderExtensionsToolsTests : LoggedTest, IAsyncDisposable
|
|||
{
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
var e = await Assert.ThrowsAsync<McpClientException>(async () => await client.CallToolAsync(
|
||||
var e = await Assert.ThrowsAsync<McpException>(async () => await client.CallToolAsync(
|
||||
"NotRegisteredTool",
|
||||
cancellationToken: TestContext.Current.CancellationToken));
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,6 @@ public class McpServerResourceTests
|
|||
});
|
||||
});
|
||||
var sp = services.BuildServiceProvider();
|
||||
Assert.Throws<McpServerException>(() => sp.GetRequiredService<IMcpServer>());
|
||||
Assert.Throws<McpException>(() => sp.GetRequiredService<IMcpServer>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class McpServerTests : LoggedTest
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestSamplingAsync_Should_Throw_McpServerException_If_Client_Does_Not_Support_Sampling()
|
||||
public async Task RequestSamplingAsync_Should_Throw_McpException_If_Client_Does_Not_Support_Sampling()
|
||||
{
|
||||
// Arrange
|
||||
await using var transport = new TestServerTransport();
|
||||
|
|
@ -131,7 +131,7 @@ public class McpServerTests : LoggedTest
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestRootsAsync_Should_Throw_McpServerException_If_Client_Does_Not_Support_Roots()
|
||||
public async Task RequestRootsAsync_Should_Throw_McpException_If_Client_Does_Not_Support_Roots()
|
||||
{
|
||||
// Arrange
|
||||
await using var transport = new TestServerTransport();
|
||||
|
|
@ -523,7 +523,7 @@ public class McpServerTests : LoggedTest
|
|||
await using var transport = new TestServerTransport();
|
||||
var options = CreateOptions(serverCapabilities);
|
||||
|
||||
Assert.Throws<McpServerException>(() => McpServerFactory.Create(transport, options, LoggerFactory));
|
||||
Assert.Throws<McpException>(() => McpServerFactory.Create(transport, options, LoggerFactory));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public class SseServerIntegrationTests : LoggedTest, IClassFixture<SseServerInte
|
|||
|
||||
// act
|
||||
await using var client = await GetClientAsync();
|
||||
await Assert.ThrowsAsync<McpClientException>(() =>
|
||||
await Assert.ThrowsAsync<McpException>(() =>
|
||||
client.GetPromptAsync("non_existent_prompt", null, cancellationToken: TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue