using OpenHarbor.MCP.Client.Core.Exceptions; using Xunit; namespace OpenHarbor.MCP.Client.Core.Tests.Exceptions; /// /// Unit tests for MCP exception types. /// Tests exception creation, messages, and properties. /// public class McpConnectionExceptionTests { [Fact] public void McpConnectionException_WithMessage_CreatesException() { // Arrange & Act var exception = new McpConnectionException("Test error"); // Assert Assert.Equal("Test error", exception.Message); Assert.Null(exception.InnerException); } [Fact] public void McpConnectionException_WithInnerException_CreatesException() { // Arrange var innerException = new InvalidOperationException("Inner error"); // Act var exception = new McpConnectionException("Test error", innerException); // Assert Assert.Equal("Test error", exception.Message); Assert.Same(innerException, exception.InnerException); } [Fact] public void ServerNotFoundException_WithServerName_SetsProperties() { // Arrange & Act var exception = new ServerNotFoundException("test-server"); // Assert Assert.Equal("test-server", exception.ServerName); Assert.Contains("test-server", exception.Message); Assert.Contains("not found or not connected", exception.Message); } [Fact] public void ToolNotFoundException_WithServerAndToolName_SetsProperties() { // Arrange & Act var exception = new ToolNotFoundException("test-server", "test_tool"); // Assert Assert.Equal("test-server", exception.ServerName); Assert.Equal("test_tool", exception.ToolName); Assert.Contains("test_tool", exception.Message); Assert.Contains("test-server", exception.Message); Assert.Contains("not found on server", exception.Message); } }