Forge
csharp3407750f
1using AgentForge.Abstractions;
2using AgentForge.Plugin.Grouping.Core;
3using AgentForge.Plugin.Grouping.Releases;
4
5namespace AgentForge.Tests;
6
7public sealed class ForgeReleaseAxisCatalogTests
8{
9 [Fact]
10 public void Catalog_lists_axes_in_order()
11 {
12 var catalog = new ForgeGroupingAxisCatalog<IForgeReleaseGroupingAxis, ForgeReleaseListItem>(
13 [
14 new TestAxis("published", "Published", order: 30),
15 new TestAxis("channel", "Channel", order: 10),
16 new TestAxis("target_platform", "Platform", order: 40),
17 ],
18 "release");
19
20 Assert.Equal(["channel", "published", "target_platform"], catalog.Axes.Select(axis => axis.Id).ToList());
21 }
22
23 [Fact]
24 public void ParseStack_skips_unknown_axes()
25 {
26 var catalog = new ForgeGroupingAxisCatalog<IForgeReleaseGroupingAxis, ForgeReleaseListItem>(
27 [new TestAxis("channel", "Channel", order: 10)],
28 "release");
29
30 var stack = catalog.ParseStack("channel,not-real,major");
31
32 Assert.Equal(["channel"], stack);
33 }
34
35 [Fact]
36 public void GroupingService_builds_groupStack_url()
37 {
38 var catalog = new ForgeGroupingAxisCatalog<IForgeReleaseGroupingAxis, ForgeReleaseListItem>(
39 [new TestAxis("channel", "Channel", order: 10)],
40 "release");
41 var grouping = new ForgeReleaseListGroupingService(catalog);
42 var context = new ForgeReleaseListViewContext("org/repo", "/view/repos/org/repo/releases", []);
43
44 var url = grouping.BuildListUrl(context, ["channel"]);
45
46 Assert.Equal("/view/repos/org/repo/releases?groupStack=channel", url);
47 }
48
49 private sealed class TestAxis(string id, string label, int order) : IForgeReleaseGroupingAxis
50 {
51 public string Id => id;
52
53 public string Label => label;
54
55 public int Order => order;
56
57 public string GetKey(ForgeReleaseListItem item, DateTimeOffset utcNow) => id;
58
59 public IReadOnlyList<ForgeGroupingSection> SectionsFor(
60 IReadOnlyList<ForgeReleaseListItem> items,
61 DateTimeOffset utcNow) => [new("only", "Only")];
62 }
63}
64
View only · write via MCP/CIDE