using System.Text.Json; using OpenHarbor.MCP.Client.Core.Models; using Xunit; namespace OpenHarbor.MCP.Client.Core.Tests.Models; /// /// Unit tests for McpTool model. /// Tests tool creation and property validation. /// public class McpToolTests { [Fact] public void Constructor_WithRequiredProperties_CreatesTool() { // Arrange & Act var tool = new McpTool { Name = "test_tool", Description = "Test tool description" }; // Assert Assert.Equal("test_tool", tool.Name); Assert.Equal("Test tool description", tool.Description); Assert.Null(tool.Schema); } [Fact] public void Constructor_WithSchema_StoresSchema() { // Arrange var schema = JsonDocument.Parse(""" { "type": "object", "properties": { "param1": {"type": "string"} } } """); // Act var tool = new McpTool { Name = "test_tool", Description = "Test description", Schema = schema }; // Assert Assert.Equal("test_tool", tool.Name); Assert.NotNull(tool.Schema); Assert.Equal("object", tool.Schema.RootElement.GetProperty("type").GetString()); } [Fact] public void Constructor_WithoutSchema_HasNullSchema() { // Arrange & Act var tool = new McpTool { Name = "simple_tool", Description = "Simple tool without parameters" }; // Assert Assert.Null(tool.Schema); } }