agentleFS
ag-ui-protocolag-ui-protocol/ag-ui/.github/skills/agui-dotnet-unit-tests/SKILL.md

agui-dotnet-unit-tests

Skill16k starsChanged 9 months agoMITView on GitHub

Author unit tests for the AG-UI .NET SDK (the *.UnitTests projects), following the SDK's serialization and compatibility conventions. USE FOR: adding unit-test coverage for a new type/method in AGUI.Abstractions/Formatting/Protobuf/Client/Server, event serialization round-trips, JsonDocument property-name assertions, backward-compatibility fixtures against TypeScript JSON, protobuf codec round-trips, client builder/handler tests, server ChatResponseUpdate conversion tests, SSE formatter tests. DO NOT USE FOR: HTTP pipeline / WebApplicationFactory end-to-end tests (use the agui-dotnet-integration-tests skill), cross-language TS↔C# server-parity tests (use the cross-language test skill).

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 2 mentionsApr 2026: 2 mentionsMay 2026: 0 mentionsJun 2026: 1 mentionJul 2026: 3 mentionsAug 2026: 4 mentionsSep 2026: 6 mentionsOct 2026: 18 mentionsNov 2026: 5 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the ag-ui-protocol/ag-ui repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about ag-ui-protocol/ag-ui

The biggest 5 of 56 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 56

Talked about on GitHub, Bluesky and Hacker News (56 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 5

On Hacker News · 1

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All commands run from sdks/dotnet/.

    line 22
  2. Very specific:

    Run one project: dotnet test tests/AGUI.Abstractions.UnitTests/

    line 34
  3. Very specific:

    Test files live directly under the project root (not mirrored into Events/ subfolders).

    line 38
  4. Very specific:

    Test class name: {TypeUnderTest}Test (RunStartedEventTest, ToolCallBuilderTest).

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AG-UI .NET Unit Tests

Conventions for the tests/*.UnitTests projects. Mined from sdks/dotnet/AGENTS.md and existing tests. An agent gets these wrong by default: asserting on deserialized objects (misses naming bugs), comparing full JSON strings (fragile), using reflection, or skipping the FixtureLoader compatibility pattern.

All commands run from sdks/dotnet/.

Unit-test projects

ProjectFocus
tests/AGUI.Abstractions.UnitTests/Event serialization round-trips; backward compat vs TypeScript fixtures (Compatibility/)
tests/AGUI.Protobuf.UnitTests/Protobuf codec round-trips; JsonElement↔protobuf Value conversion
tests/AGUI.Client.UnitTests/Client builders, content-negotiation handler, transport, protocol rules
tests/AGUI.Server.UnitTests/ChatResponseUpdate → AG-UI event conversion
tests/AGUI.Formatting.UnitTests/SSE event-stream formatter (read/write, media type)

Run one project: dotnet test tests/AGUI.Abstractions.UnitTests/

Conventions

  • Test files live directly under the project root (not mirrored into Events/ subfolders). Compatibility tests go in the Compatibility/ subfolder.
  • Test class name: {TypeUnderTest}Test (RunStartedEventTest, ToolCallBuilderTest). Compatibility class: {Category}CompatibilityTest (RunEventsCompatibilityTest).
  • public sealed class, one class per file, file name matches type.
  • [Fact] for single cases, [Theory] + [InlineData] for parameterized cases.
  • Serialize via the source-generated context: AGUIJsonSerializerContext.Default.{Type} — never JsonSerializer.Serialize<object>(...) or hand-rolled options.

Pattern 1 — Event serialization round-trip (Abstractions)

Serialize via the source-gen context, parse with JsonDocument, assert each camelCase property name AND the type discriminator. This is what catches [JsonPropertyName] bugs.

[Fact]
public void Serialization_RoundTrips()
{
    var evt = new RunStartedEvent { ThreadId = "t1", RunId = "r1", Timestamp = 1234567890 };

    var json = JsonSerializer.Serialize(evt, AGUIJsonSerializerContext.Default.RunStartedEvent);
    using var doc = JsonDocument.Parse(json);

    Assert.Equal("RUN_STARTED", doc.RootElement.GetProperty("type").GetString());
    Assert.Equal("t1", doc.RootElement.GetProperty("threadId").GetString());
    Assert.Equal("r1", doc.RootElement.GetProperty("runId").GetString());
    Assert.Equal(1234567890, doc.RootElement.GetProperty("timestamp").GetInt64());
}

Pattern 2 — Backward-compatibility fixtures (Abstractions/Compatibility)

Compatibility/Fixtures/*.json are produced by the TypeScript reference implementation. Deserialize them into .NET types and assert the values — this catches wire-format drift. Load arrays with FixtureLoader; write one test method per event shape.

public sealed class RunEventsCompatibilityTest
{
    private readonly JsonElement[] _fixtures = FixtureLoader.LoadFixture("run-events.json");

    [Fact]
    public void RunStartedEvent_DeserializesFromTypeScriptPayload()
    {
        var evt = FixtureLoader.DeserializeAsBaseEvent(_fixtures[0]);

        var typed = Assert.IsType<RunStartedEvent>(evt);
        Assert.Equal("thread-1234", typed.ThreadId);
        Assert.Equal("run-5678", typed.RunId);
    }
}

Adding a fixture: place the TS-produced JSON array under Compatibility/Fixtures/ (embedded resource), then index into the loaded array per shape.

Pattern 3 — Protobuf codec round-trip (Protobuf)

Encode→decode and assert typed values. Compare JsonElement payloads with JsonTestHelpers.AssertEqual (deep-equals), not string compare. ProtoValueConverter tests verify JsonElement↔Value for each ValueKind.

var result = RoundTrip(new RunStartedEvent { ThreadId = "thread-1", RunId = "run-1" });
Assert.Equal("thread-1", result.ThreadId);
JsonTestHelpers.AssertEqual(expectedElement, result.RawEvent!.Value);

Pattern 4 — Client builders / handler (Client)

Drive the builder/handler through its real API and assert the produced MEAI types. ToolCallBuilder/TextMessageBuilder: feed events, flush, assert FunctionCallContent, ConversationId, ResponseId. AGUIEventStreamHandler: assert content-negotiation Accept header ordering via a test inner handler. Standard xunit assertions.

Pattern 5 — Server conversion (Server)

Convert a ChatResponseUpdate stream to AG-UI events and assert the sequence with Assert.Collection, type-checking each event and its fields (e.g. run lifecycle wraps content with RunStartedEvent/RunFinishedEvent).

Pattern 6 — SSE formatter (Formatting)

Assert MediaType, CanRead(contentType) (use [Theory]/[InlineData] for case and null/empty handling), and that WriteAsync produces the data: {json} shape per event.

❌ Critical anti-patterns

  1. Never assert only on the deserialized object for serialization tests. Round-trip through your own type hides [JsonPropertyName] mistakes. Parse the JSON with JsonDocument and assert the literal camelCase property names + type discriminator.
  2. Never compare full JSON strings — fragile against property ordering/whitespace. Parse and check individual properties (or JsonTestHelpers.AssertEqual for payloads).
  3. Never use reflection to enumerate types or verify membership. Write explicit per-type / per-shape tests.
  4. Never use ad-hoc serializer options. Serialize through AGUIJsonSerializerContext.Default.{Type} so tests exercise the real AOT context.
  5. Never collapse compatibility shapes into one loop-only assertion. Keep one test method per event shape so a drift failure names the exact event.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.