| 1 | using AgentForge.Abstractions; |
| 2 | using AgentForge.Services; |
| 3 | |
| 4 | namespace AgentForge.Tests; |
| 5 | |
| 6 | public sealed class ForgeCommandCatalogTests |
| 7 | { |
| 8 | [Fact] |
| 9 | public void Build_rejects_duplicate_doi_across_plugins() |
| 10 | { |
| 11 | var plugins = new IForgePlugin[] |
| 12 | { |
| 13 | new StubForgePlugin("plugin-a", "forge.issue.open.a"), |
| 14 | new StubForgePlugin("plugin-b", "forge.issue.open.b"), |
| 15 | }; |
| 16 | |
| 17 | var ex = Assert.Throws<InvalidOperationException>(() => ForgeCommandCatalog.Build(plugins)); |
| 18 | Assert.Contains("Duplicate command DOI 'issue.open'", ex.Message, StringComparison.Ordinal); |
| 19 | } |
| 20 | |
| 21 | private sealed class StubForgePlugin(string id, string commandId) : IForgePlugin |
| 22 | { |
| 23 | public string Id => id; |
| 24 | |
| 25 | public string DisplayName => id; |
| 26 | |
| 27 | public void ConfigureServices(Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | public void MapEndpoints(Microsoft.AspNetCore.Builder.WebApplication app) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | public void RegisterCommands(ForgeCommandRegistry registry) => |
| 36 | registry.Add(new ForgeCommandDescriptor |
| 37 | { |
| 38 | Domain = "forge", |
| 39 | Object = "issue", |
| 40 | Intent = "open", |
| 41 | CommandId = commandId, |
| 42 | Path = $"/{id}-issue-open", |
| 43 | }); |
| 44 | } |
| 45 | } |
| 46 | |
View only · write via MCP/CIDE