using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NUnit.Framework; using MCPForUnity.Editor.Tools; namespace MCPForUnityTests.Editor.Tools { public class CommandRegistryTests { [Test] public void GetHandler_ThrowsException_ForUnknownCommand() { var unknown = "nonexistent_command_that_should_not_exist"; Assert.Throws(() => { CommandRegistry.GetHandler(unknown); }, "Should throw InvalidOperationException for unknown handler"); } [Test] public void AutoDiscovery_RegistersAllBuiltInTools() { // Verify that all expected built-in tools are registered by trying to get their handlers var expectedTools = new[] { "manage_asset", "manage_editor", "manage_gameobject", "manage_scene", "manage_script", "manage_shader", "read_console", "manage_menu_item", "manage_prefabs" }; foreach (var toolName in expectedTools) { Assert.DoesNotThrow(() => { var handler = CommandRegistry.GetHandler(toolName); Assert.IsNotNull(handler, $"Handler for '{toolName}' should not be null"); }, $"Expected tool '{toolName}' to be auto-registered"); } } } }