| 1 | using System.Text.Json; |
| 2 | using AgentForge.Services; |
| 3 | |
| 4 | namespace AgentForge.Tests; |
| 5 | |
| 6 | public sealed class ForgeIopEventTests |
| 7 | { |
| 8 | [Fact] |
| 9 | public void ToEnvelope_includes_actor_refs_and_payload() |
| 10 | { |
| 11 | var envelope = ForgeIopEvent.ForIssue( |
| 12 | "issue.comment", |
| 13 | "agents-sandbox", |
| 14 | 3, |
| 15 | new { body = "hi" }, |
| 16 | "oar:Nova").ToEnvelope(); |
| 17 | |
| 18 | var json = JsonSerializer.Serialize(envelope); |
| 19 | using var doc = JsonDocument.Parse(json); |
| 20 | var root = doc.RootElement; |
| 21 | Assert.Equal("oar:Nova", root.GetProperty("actor").GetString()); |
| 22 | Assert.Equal("issue.comment", root.GetProperty("kind").GetString()); |
| 23 | Assert.Equal("agents-sandbox", root.GetProperty("refs").GetProperty("repo").GetString()); |
| 24 | Assert.Equal(3, root.GetProperty("refs").GetProperty("issue").GetInt32()); |
| 25 | Assert.Equal("hi", root.GetProperty("payload").GetProperty("body").GetString()); |
| 26 | } |
| 27 | } |
| 28 | |
View only · write via MCP/CIDE