New Event Source
aws/aws-lambda-dotnet
Add a new AWS event source attribute (e.g., Kinesis, Kafka, MQ) to the Lambda .NET Annotations framework, including the attribute class, source generator integration, CloudFormation writer, unit…
Guidelines for writing unit tests in the Hex1b TUI library. An agent skill from mitchdenny/hex1b.
$ npx skills add mitchdenny/hex1b --skill writing-unit-tests -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install mitchdenny/hex1b writing-unit-tests --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/mitchdenny/hex1b.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/skills/writing-unit-tests .claude/skills/writing-unit-tests && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "writing-unit-tests" agent skill from https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-tests into .claude/skills/writing-unit-tests/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "writing-unit-tests", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-testsType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add mitchdenny/hex1b --skill writing-unit-tests -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install mitchdenny/hex1b writing-unit-tests --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mitchdenny/hex1b.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.github/skills/writing-unit-tests .agents/skills/writing-unit-tests && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "writing-unit-tests" agent skill from https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-tests into .agents/skills/writing-unit-tests/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "writing-unit-tests", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add mitchdenny/hex1b --skill writing-unit-tests -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install mitchdenny/hex1b writing-unit-tests --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mitchdenny/hex1b.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.github/skills/writing-unit-tests .cursor/skills/writing-unit-tests && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "writing-unit-tests" agent skill from https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-tests into .cursor/skills/writing-unit-tests/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "writing-unit-tests", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/mitchdenny/hex1b.git --path .github/skills/writing-unit-tests--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add mitchdenny/hex1b --skill writing-unit-tests -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install mitchdenny/hex1b writing-unit-tests --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mitchdenny/hex1b.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.github/skills/writing-unit-tests .gemini/skills/writing-unit-tests && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "writing-unit-tests" agent skill from https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-tests into .gemini/skills/writing-unit-tests/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "writing-unit-tests", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install mitchdenny/hex1b writing-unit-testsInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add mitchdenny/hex1b --skill writing-unit-tests -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/mitchdenny/hex1b.git skills-src && mkdir -p .github/skills && cp -r skills-src/.github/skills/writing-unit-tests .github/skills/writing-unit-tests && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "writing-unit-tests" agent skill from https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-tests into .github/skills/writing-unit-tests/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "writing-unit-tests", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add mitchdenny/hex1b --skill writing-unit-tests -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install mitchdenny/hex1b writing-unit-tests --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mitchdenny/hex1b.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.github/skills/writing-unit-tests .opencode/skills/writing-unit-tests && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "writing-unit-tests" agent skill from https://github.com/mitchdenny/hex1b/tree/main/.github/skills/writing-unit-tests into .opencode/skills/writing-unit-tests/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "writing-unit-tests", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
writing-unit-testsGuidelines for writing unit tests in the Hex1b TUI library. An agent skill from mitchdenny/hex1b.
Writing Unit Tests is an agent skill from mitchdenny/hex1b. Guidelines for writing unit tests in the Hex1b TUI library. Use when creating new tests for widgets, nodes, or terminal functionality.
Its SKILL.md is about 7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Testing & QA, covering Unit testing. It works with .NET. The repository describes itself as: The .NET Terminal Application Stack. The licence is MIT.
4 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit e2335bd. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
dotnetFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Writing Unit Tests loads about 7k tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 2,012 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from mitchdenny/hex1b at commit e2335bd, republished under its MIT licence (© mitchdenny). 2,012 words, ~7,015 tokens.
.claude/skills/writing-unit-tests/SKILL.md (or your agent's skills folder).This skill provides guidelines for AI agents writing unit tests for the Hex1b TUI library. It outlines the preferred testing approach, patterns, and anti-patterns to avoid. Tests use MSTest 4 with MSTest.Sdk/4.2.3, OutputType=Exe, and Microsoft.Testing.Platform (MTP). global.json configures dotnet test to use MTP; test projects can also run in executable mode with dotnet run --project tests/SomeProject/.
Hex1bTerminal.CreateBuilder() to create complete terminal environments.WithHex1bApp() for TUI functionality tests - This wires up the full app lifecycleCellPatternSearcher and color assertions for render verification| Test Type | Approach |
|---|---|
| Widget behavior, layout, rendering | Full stack with Hex1bTerminal.CreateBuilder() |
| Input handling, focus navigation | Full stack with WithHex1bApp() |
| Low-level APIs (Surface, SurfaceCell) | Test in isolation (dependencies of Hex1bApp) |
| Color/theme verification | Full stack with snapshot color assertions |
Test files import Microsoft.VisualStudio.TestTools.UnitTesting. The Hex1b.Testing namespace is global-using'd via Directory.Build.props for helpers such as TestSeq. For test output, add public TestContext TestContext { get; set; } = null!; and call TestContext.WriteLine(...). Suppressed MSTest analyzers are MSTEST0014, MSTEST0030, MSTEST0032, and MSTEST0057.
This is the preferred pattern for most tests:
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class WidgetNameTests
{
[TestMethod]
public async Task WidgetName_Scenario_ExpectedBehavior()
{
// Arrange - Build the terminal with the app
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithHex1bApp((app, options) => ctx => new VStackWidget([
new TextBlockWidget("Hello"),
new ButtonWidget("Click Me")
]))
.WithHeadless()
.WithDimensions(80, 24)
.Build();
// Act & Assert - Use input sequencer with WaitUntil
var snapshot = await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Hello"), TimeSpan.FromSeconds(2), "initial render")
.Down() // Navigate to button
.WaitUntil(s => s.ContainsText("> Click Me"), TimeSpan.FromSeconds(2), "button focused")
.Capture("focused-button")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);
// Assert (often redundant if WaitUntil already verified)
Assert.IsTrue(snapshot.ContainsText("> Click Me"));
}
}await using var terminal - Ensures proper disposal.WithHeadless() - No actual terminal output (CI-safe).WithDimensions(80, 24) - Explicit terminal sizeWaitUntil before assertions - Prevents timing issues.Capture("name") - Saves SVG/HTML for debuggingCtrl().Key(Hex1bKey.C) - Clean exitawait new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Item 1"), TimeSpan.FromSeconds(2), "list rendered")
.Down()
.WaitUntil(s => s.ContainsText("> Item 2"), TimeSpan.FromSeconds(2), "moved to item 2")
.Down()
.WaitUntil(s => s.ContainsText("> Item 3"), TimeSpan.FromSeconds(2), "moved to item 3")
.Capture("navigation-result")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Name:"), TimeSpan.FromSeconds(2), "form rendered")
.Type("John Doe")
.WaitUntil(s => s.ContainsText("John Doe"), TimeSpan.FromSeconds(2), "text entered")
.Capture("text-input")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Ready"), TimeSpan.FromSeconds(2), "app ready")
.Ctrl().Key(Hex1bKey.S) // Ctrl+S
.WaitUntil(s => s.ContainsText("Saved"), TimeSpan.FromSeconds(2), "save completed")
.Capture("after-save")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);For precise cell-level assertions:
// Find a specific character
var pattern = new CellPatternSearcher().Find('█');
var result = pattern.Search(snapshot);
Assert.IsTrue(result.HasMatches);
Assert.AreEqual(expectedX, result.First!.Start.X);
// Find with regex pattern
var pattern = new CellPatternSearcher().FindPattern(@"Count:\s*\d+");
var result = pattern.Search(snapshot);
Assert.IsTrue(result.HasMatches);
// Find with predicate
var pattern = new CellPatternSearcher()
.Find(ctx => char.IsDigit(ctx.Cell.Character[0]));
var result = pattern.Search(snapshot);
Assert.AreEqual(3, result.Count);For verifying themed/styled output:
// Check if any cell has a specific background color
Assert.IsTrue(snapshot.HasBackgroundColor(Hex1bColor.FromRgb(0, 100, 200)),
"Button should have blue background");
// Check if any cell has a specific foreground color
Assert.IsTrue(snapshot.HasForegroundColor(Hex1bColor.FromRgb(255, 255, 255)),
"Text should be white");
// Get color at specific position
var bgColor = snapshot.GetBackgroundColor(10, 5);
Assert.AreEqual(Hex1bColor.FromRgb(255, 0, 0), bgColor);
// Check uniform row background
Assert.IsTrue(snapshot.HasUniformBackgroundColor(0, Hex1bColor.FromRgb(50, 50, 50)),
"Header row should have dark background");| Method | Purpose |
|---|---|
HasBackgroundColor() | Any cell has a background color |
HasBackgroundColor(Hex1bColor) | Any cell has specific background |
HasForegroundColor() | Any cell has a foreground color |
HasForegroundColor(Hex1bColor) | Any cell has specific foreground |
GetBackgroundColor(x, y) | Get background at position |
GetForegroundColor(x, y) | Get foreground at position |
HasUniformBackgroundColor(y, color) | All cells in row have same background |
VisualizeBackgroundColors() | Debug helper with visual representation |
📘 See the
test-fixerskill for detailed diagnosis and fixes when tests become flaky.
// BROKEN: Waits for partial content, but rest of screen may not be rendered
await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Header"), TimeSpan.FromSeconds(2)) // ❌ Only checks header
.Capture("screen")
.Build()
.ApplyAsync(terminal, ct);
// Assertion on footer may fail - it wasn't part of the WaitUntil!
Assert.IsTrue(snapshot.ContainsText("Footer"));Problem: Rendering is inherently async. Finding "Header" doesn't guarantee "Footer" has rendered yet. This is especially problematic when testing other terminal frameworks (like Spectre Console) which may drop input if they're not ready to receive it.
Fix: Over-specify the WaitUntil condition to ensure everything you need is present:
// ✅ Wait for ALL content you'll assert on
await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Header") && s.ContainsText("Footer"),
TimeSpan.FromSeconds(2), "full screen rendered")
.Capture("screen")
.Build()
.ApplyAsync(terminal, ct);Guideline: If you're going to assert on specific screen content, include it in the WaitUntil condition. Don't assume the rest of the screen is ready just because one part appeared.
// BROKEN: Snapshot taken AFTER Ctrl+C clears the buffer
var snapshot = await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Hello"), TimeSpan.FromSeconds(2))
.Capture("final")
.Ctrl().Key(Hex1bKey.C) // Buffer may be cleared before snapshot!
.Build()
.ApplyWithCaptureAsync(terminal, ct);
Assert.IsTrue(snapshot.ContainsText("Hello")); // ❌ May fail on Linux CIFix: The WaitUntil already verified the content. If you need to assert, the WaitUntil serves as the assertion.
// BROKEN: No wait for render after Down()
await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Item 1"), TimeSpan.FromSeconds(2))
.Down()
.Capture("after-down") // ❌ Render may not be complete!
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyAsync(terminal, ct);Fix: Always add WaitUntil after any action that changes state:
.Down()
.WaitUntil(s => s.ContainsText("> Item 2"), TimeSpan.FromSeconds(2), "moved down")
.Capture("after-down")// BROKEN: Fixed delay may not be long enough on slow CI
await terminal.SendKeyAsync(Hex1bKey.Enter);
await Task.Delay(100); // ❌ Arbitrary delay
Assert.IsTrue(eventFired);Fix: Use TaskCompletionSource to signal completion:
var eventSignal = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
// In event handler:
eventSignal.TrySetResult();
// In test:
await eventSignal.Task.WaitAsync(TimeSpan.FromSeconds(2), ct);// AVOID: Too many layers of abstraction
var result = await TestHelpers.CreateTerminalAndRunScenario(
widgets: WidgetFactory.CreateStandardList(),
actions: ActionBuilder.NavigateAndSelect(3),
assertions: AssertionBuilder.SelectedItem("Item 3")
);Prefer: Simple, linear, self-contained tests. Repetition is acceptable and helps AI agents understand patterns.
Use queued in-memory presentation reads with Hex1bAppWorkloadAdapter. Observe
the escape timer's finite ITimer.Change before firing its callback; observing
CreateTimer alone is insufficient because it is initially disabled. Keep other
timers (such as synchronized output) independent in the controlled provider.
For example, Hex1bTerminalTests.PresentationInput_PasteEscapeAcrossTimeout_PreservesLiteralContent
queues "\x1b[200~a\x1b", waits for arming, fires expiry, then queues
"\rb\x1b[201~z". Read through the post-paste z sentinel before asserting
exact completed paste text and no surplus events. This avoids sleeps and makes
read-boundary/timeout bugs reproducible. At app level, bind on the focused widget
and prove the same Escape binding fires for an ordinary Escape after the paste.
Let the server reserve its listening port atomically. Random port selection and
probing a free port before closing the probe both allow collisions under parallel
execution. For Kestrel fixtures, configure
options.Listen(IPAddress.Loopback, 0), await app.StartAsync(), then derive client
URIs from TestSeq.Single(app.Urls). For example:
var wsUri = new UriBuilder(TestSeq.Single(app.Urls))
{
Scheme = "ws",
Path = "/ws/attach"
}.Uri;Keep the application owned by the fixture before awaiting startup so cleanup can
dispose it even if startup fails. Cover independently reachable concurrent servers
and listener release; see RemoteTerminalWorkloadAdapterTests. Do not mask port
collisions with sleeps, retries, or disabled parallelism.
For starvation regressions, keep the producer active while asserting input, timer,
or shutdown progress. A finite output burst followed by app.Invalidate() can
hide a lost wakeup. Use TestWidget.OnRender to place events at a known frame:
var observer = new TestWidget().OnRender(args =>
{
app.Invalidate(); // Renew on every frame, including while input is pending.
if (args.RenderCount == 3)
workload.SendKey(Hex1bKey.A);
});This fragment assumes captured app and workload references. Pair it with
changing visible content so frames actually render, a bounded completion signal,
and cancellation in finally. See Hex1bAppSchedulingTests for full examples.
Check input ordering with coalescing both enabled and disabled. For exact cadence,
use the app's internal FrameTimeProvider with a fake clock, wait for timer
registration before advancing it, and assert both the requested delay and elapsed
virtual time. A fixed wall-clock tolerance around Task.Delay is not portable
across CI runners. Keep real-time full-stack tests alongside deterministic pacing
coverage rather than widening timing tolerances.
For nested output races, gate later child redraws: their extra notifications can
mask a lost first-frame notification. These controlled cases supplement, rather
than prove, responsiveness under arbitrary real-world load.
Process exit and terminal output consumption are separate events. For a controlled
regression, start a StandardProcessWorkloadAdapter and await its exit before
constructing a terminal with an already-completed run callback. Gate the first
presentation write with a TaskCompletionSource: RunAsync and lifecycle
completion must remain pending until the gate is released and both stdout and
stderr reach the snapshot. See StandardProcessOutputTests for raw and filtered
output, cancellation, and pump-failure cases. Keep ordinary WithProcess tests
alongside this ordering test; do not keep a one-shot child alive or wait for visible
output before awaiting RunAsync in a drain regression, since that hides the race.
For echo/transport tests, use an already-available executable (cmd /d /c echo on
Windows, /bin/echo on Unix). Runtime-compiling a temporary C# program with
dotnet run puts SDK startup and compilation inside the output deadline.
Test each endpoint against a scripted peer with pinned numeric frame types, little-endian headers, and literal JSON from the pre-change protocol. Do not use the production codec on the simulated legacy side: otherwise both endpoints can change together and conceal a wire regression. Preserve the existing mandatory ActivityState handshake baseline; these fixtures model the build immediately before the shutdown change, not every historical HMP1 implementation.
See Hmp1ShutdownCompatibilityTests: the server fixture sends a literal
ClientHello and Input, gates a large Output write, then independently decodes
Output, Output, Exit and EOF without sending acknowledgements. The client fixture
feeds Hello, StateSync, ActivityState, split-UTF-8 Output and Exit or EOF, gates
presentation, and checks exact final bytes and the snapshot at lifecycle
completion. Include premature Exit and truncated final frames to establish that
missing content cannot be recovered. Confirm the relevant tests fail when server
ordering or client draining is temporarily removed, then restore both safeguards.
When writing tests for widgets, consider all the dimensions that affect behavior. Each widget should have tests covering these scenarios:
Widgets must work across different terminal sizes. Use MSTest DataRow for parameterized cases:
[TestMethod]
[DataRow(40, 10)] // Minimum realistic size
[DataRow(80, 24)] // Standard terminal
[DataRow(120, 40)] // Large terminal
[DataRow(200, 60)] // Very large terminal
public async Task ListWidget_VariousTerminalSizes_RendersCorrectly(int width, int height)
{
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithHex1bApp((app, options) => ctx => new ListWidget(["Item 1", "Item 2", "Item 3"]))
.WithHeadless()
.WithDimensions(width, height)
.Build();
await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Item 1"), TimeSpan.FromSeconds(2), "list rendered")
.Capture($"list-{width}x{height}")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyAsync(terminal, TestContext.Current.CancellationToken);
}Key questions to answer:
Widgets behave differently depending on their parent container. Test inside various layouts:
[TestMethod]
public async Task ProgressWidget_InsideBorder_RendersWithCorrectWidth()
{
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithHex1bApp((app, options) => ctx => new BorderWidget(
new ProgressWidget { Value = 50, Maximum = 100 },
title: "Loading"
))
.WithHeadless()
.WithDimensions(60, 10)
.Build();
await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Loading"), TimeSpan.FromSeconds(2), "border rendered")
.Capture("progress-in-border")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyAsync(terminal, TestContext.Current.CancellationToken);
}
[TestMethod]
public async Task Button_InsideHStack_SharesSpaceCorrectly()
{
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithHex1bApp((app, options) => ctx => new HStackWidget([
new ButtonWidget("Cancel"),
new ButtonWidget("OK")
]))
.WithHeadless()
.WithDimensions(40, 5)
.Build();
await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Cancel") && s.ContainsText("OK"), TimeSpan.FromSeconds(2))
.Capture("buttons-in-hstack")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyAsync(terminal, TestContext.Current.CancellationToken);
}Common container scenarios to test:
VStackWidget (vertical stacking)HStackWidget (horizontal stacking)BorderWidget (reduced available space)ScrollPanelWidget (scrollable content)SplitterWidget (resizable panes)Verify that widgets respect theme colors and can be customized:
[TestMethod]
public async Task Button_WithCustomTheme_UsesThemeColors()
{
var customTheme = new Hex1bTheme("TestTheme")
.Set(ButtonTheme.BackgroundColor, Hex1bColor.FromRgb(255, 0, 0))
.Set(ButtonTheme.ForegroundColor, Hex1bColor.FromRgb(255, 255, 255));
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithHex1bApp((app, options) =>
{
options.Theme = customTheme;
return ctx => new ButtonWidget("Test Button");
})
.WithHeadless()
.WithDimensions(40, 5)
.Build();
var snapshot = await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Test Button"), TimeSpan.FromSeconds(2))
.Capture("themed-button")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);
Assert.IsTrue(snapshot.HasBackgroundColor(Hex1bColor.FromRgb(255, 0, 0)),
"Button should have red background from theme");
Assert.IsTrue(snapshot.HasForegroundColor(Hex1bColor.FromRgb(255, 255, 255)),
"Button should have white text from theme");
}
[TestMethod]
public async Task Button_FocusedState_UsesFocusedThemeColors()
{
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithHex1bApp((app, options) => ctx => new VStackWidget([
new TextBlockWidget("Header"),
new ButtonWidget("Focusable Button")
]))
.WithHeadless()
.WithDimensions(40, 5)
.Build();
var snapshot = await new Hex1bTerminalInputSequenceBuilder()
.WaitUntil(s => s.ContainsText("Focusable Button"), TimeSpan.FromSeconds(2))
.Tab() // Focus the button
.WaitUntil(s => s.ContainsText(">"), TimeSpan.FromSeconds(2), "button focused")
.Capture("focused-button-theme")
.Ctrl().Key(Hex1bKey.C)
.Build()
.ApplyWithCaptureAsync(terminal, TestContext.Current.CancellationToken);
// Verify focused state uses different colors than unfocused
Assert.IsTrue(snapshot.HasBackgroundColor(), "Focused button should have background color");
}Theming scenarios to test:
For comprehensive widget coverage, consider this matrix:
| Dimension | Variations to Test |
|---|---|
| Terminal Size | Minimum (40×10), Standard (80×24), Large (120×40), Very Large (200×60) |
| Container | Root, VStack, HStack, Border, Scroll, Splitter, Nested |
| Theme | Default, Custom colors, Focused state, Disabled state |
| Content | Empty, Minimal, Typical, Maximum/overflow |
| State | Initial, After interaction, Edge cases |
Not every widget needs every combination, but consider which dimensions are relevant for the widget's behavior.
Measure GC.GetAllocatedBytesForCurrentThread() around a synchronous application
region, not across awaits or for the whole process. A workload filter returning
ValueTask.CompletedTask can start the measurement after parsing; the terminal's
PresentationInvalidated callback can finish it. Assert both callbacks used the
same thread. Use a large batch of allocation-free tokens (such as SGR resets)
and a byte budget that excludes per-token bookkeeping but allows fixed overhead.
Keep parsing and HWT frame generation outside the measured region, then separately
verify frame delivery and batch accounting. See Hwt1ImpactCollectionTests for
raw, pre-tokenized, and HMP StateSync coverage. Confirm the guard fails when the
optimization is disabled; behavior-only assertions do not prove allocation removal.
Use literal expected bytes independent of the production key/text mapper. For
example, Alt+Shift+E is 1B45, while Ctrl+Alt+E is 1B05 in Hex1b's legacy
automation profile. Exercise the public automator and sequence builder against a
recording workload, asserting immediately after awaited sends rather than sleeping.
See TerminalKeyboardMatrixTests for the key/modifier/cursor-mode/keypad-mode
matrix and completeness checks that fail when an enum grows. Include modifier
reset, overlap, ordering, and replay after mode changes; constructing a sequence
must not freeze its wire encoding. Keep physical layout, AltGr/IME, and negotiated
keyboard protocols distinct from this logical-key encoding contract.
Compile a separate fixture against a pinned published Hex1b package, not the
current project, and load that unchanged adapter assembly against the current
library. Assert that its implemented interface resolves to the current assembly
and that newly added default members preserve raw input delivery. Recompiling a
test adapter against the new interface proves source compatibility, not binary
compatibility. tests/Fixtures/LegacyWorkloadAdapter also provides a build-time
stdin probe: it reports exact bytes read by a child process, without runtime
compilation or depending on the child's text encoding.
Run native console tests in a child process under WindowsProxyPtyHandle, not
against the test runner's own console. WindowsConsoleProbeTests launches the
already-built test executable with an exact --filter and a child-only
environment marker; its guarded child test constructs the real console driver.
The parent acts as the terminal, waits for an explicit probe-start marker before
replying, and checks a result written through the driver. This exercises ConPTY and
ReadConsoleInputW without runtime compilation or shared-console mutation.
Do not synchronize on the outgoing KGP query: some ConPTY hosts consume APC
queries instead of forwarding them, even though input can still be tested.
Keep the existing test-host packaging unchanged rather than changing the host
for unrelated PTY tests to satisfy this fixture. Use bounded
cancellation and dispose the PTY to terminate children on assertion failures.
For APIs that are dependencies of Hex1bApp (like Surface), test in isolation:
[TestMethod]
public void Surface_WriteText_SetsCorrectCells()
{
// Arrange
var surface = new Surface(80, 24);
// Act
surface.WriteText(0, 0, "Hello");
// Assert
Assert.AreEqual('H', surface[0, 0].Character[0]);
Assert.AreEqual('e', surface[1, 0].Character[0]);
Assert.AreEqual('l', surface[2, 0].Character[0]);
Assert.AreEqual('l', surface[3, 0].Character[0]);
Assert.AreEqual('o', surface[4, 0].Character[0]);
}
[TestMethod]
public void SurfaceCell_WithColor_PreservesColor()
{
// Arrange
var cell = new SurfaceCell('X', Hex1bColor.Red, Hex1bColor.Blue);
// Assert
Assert.AreEqual('X', cell.Character[0]);
Assert.AreEqual(Hex1bColor.Red, cell.Foreground);
Assert.AreEqual(Hex1bColor.Blue, cell.Background);
}Follow MethodName_Scenario_ExpectedBehavior:
[TestMethod]
public async Task ListWidget_DownArrow_SelectsNextItem() { }
[TestMethod]
public async Task TextBox_TypeText_DisplaysInput() { }
[TestMethod]
public async Task Button_EnterKey_TriggersClickHandler() { }
[TestMethod]
public void Surface_Fill_SetsAllCellsInRegion() { }When you discover a new testing pattern while writing tests:
This builds the body of knowledge available to AI agents working on the codebase.
Hex1bTerminal.CreateBuilder() with .WithHeadless().WithHex1bApp() for TUI functionality (unless testing low-level APIs)WaitUntil after every action that changes stateWaitUntil immediately before .Capture()WaitUntil)Ctrl().Key(Hex1bKey.C)MethodName_Scenario_ExpectedBehavior namingCellPatternSearcher for precise cell assertions when needed© mitchdenny, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .github/skills/writing-unit-tests of mitchdenny/hex1b.
Open the folder on GitHubat commit e2335bd
Writing Unit Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Writing Unit Tests this skillmitchdenny/hex1b | 178 | — | ~7k | Automated safety check: Pass | MIT | |
| New Event Sourceaws/aws-lambda-dotnet | 1.7k | — | ~3k | Automated safety check: Pass | Apache-2.0 | |
| ScottPlot Test RunnerScottPlot/ScottPlot | 6.8k | — | ~308 | Automated safety check: Pass | MIT | |
| Aspire Integration TestingDevBetterCom/DevBetterWeb | 157 | 2 repos | ~2.3k | Automated safety check: Pass | None | |
| Vstest Build Testmicrosoft/vstest | 969 | — | ~1.9k | Automated safety check: Pass | MIT | |
| Coverage Analysisrunceel/ReactiveProperty | 944 | — | ~5.9k | Automated safety check: Warn | MIT |
aws/aws-lambda-dotnet
Add a new AWS event source attribute (e.g., Kinesis, Kafka, MQ) to the Lambda .NET Annotations framework, including the attribute class, source generator integration, CloudFormation writer, unit…
ScottPlot/ScottPlot
Run or add ScottPlot 5 tests. Use for unit-test and cookbook-test work; unless explicitly asked otherwise, restrict manual test execution to the Unit Tests…
DevBetterCom/DevBetterWeb
Write integration tests using .NET Aspire's testing facilities with xUnit.
microsoft/vstest
Build, test, and validate changes in the vstest repository. An agent skill from microsoft/vstest.
runceel/ReactiveProperty
Automated, project-wide code coverage and CRAP (Change Risk Anti-Patterns) score analysis for .NET projects with existing unit tests.
OpenCoreMMO/OpenCoreMMO
Write, fix, or review NeoServer unit tests using xUnit and FluentAssertions.
mitchdenny/hex1b
Guidelines for reviewing API design in the Hex1b codebase. An agent skill from mitchdenny/hex1b.
mitchdenny/hex1b
Guidelines for running and interpreting Surface API performance benchmarks.
mitchdenny/hex1b
Agent for validating Hex1b documentation against actual library behavior.
mitchdenny/hex1b
Guidelines for producing accurate and maintainable documentation for the Hex1b TUI library.
mitchdenny/hex1b
Agent for diagnosing and fixing flaky terminal UI tests in the Hex1b test suite.
mitchdenny/hex1b
Step-by-step guide for creating new widgets in the Hex1b TUI library.
Works with
Categories
Guidelines for writing unit tests in the Hex1b TUI library. An agent skill from mitchdenny/hex1b. Writing Unit Tests is an agent skill from mitchdenny/hex1b. Guidelines for writing unit tests in the Hex1b TUI library.
Writing Unit Tests fits situations like: creating new tests for widgets; terminal functionality.
Run `npx skills add mitchdenny/hex1b --skill writing-unit-tests -a claude-code`. Or copy the skill folder (.github/skills/writing-unit-tests in mitchdenny/hex1b) into .claude/skills/writing-unit-tests in your project. Claude Code loads it when a task matches its description.
Run `npx skills add mitchdenny/hex1b --skill writing-unit-tests -a codex`. Or copy the skill folder (.github/skills/writing-unit-tests in mitchdenny/hex1b) into .agents/skills/writing-unit-tests in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mitchdenny/hex1b --skill writing-unit-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/writing-unit-tests, .gemini/skills/writing-unit-tests, .github/skills/writing-unit-tests and .opencode/skills/writing-unit-tests in your project.
Going by SKILL.md and its folder, Writing Unit Tests needs the command-line tools its instructions call (dotnet).
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Writing Unit Tests is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 7k tokens (SKILL.md is roughly 28k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Writing Unit Tests: New Event Source (aws/aws-lambda-dotnet, 1.7k stars), ScottPlot Test Runner (ScottPlot/ScottPlot, 6.8k stars), Aspire Integration Testing (DevBetterCom/DevBetterWeb, 157 stars) and Vstest Build Test (microsoft/vstest, 969 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
mitchdenny (a GitHub user) maintains it in mitchdenny/hex1b, which has 178 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 9, 2026.
Source: mitchdenny/hex1b on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.