avalonia-ui-tests

Write xUnit tests for Avalonia UI controls, dialogs, and panels following project conventions.

43|30|Updated Nov 16, 2025
One-click install
npx skills add https://github.com/nikolaygekht/ballistic.calculator.app.avalonia --skill avalonia-ui-tests-nikolaygekht
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: avalonia-ui-tests
Source: https://github.com/nikolaygekht/ballistic.calculator.app.avalonia/tree/main/.claude/skills/avalonia-ui-tests
Command: npx skills add https://github.com/nikolaygekht/ballistic.calculator.app.avalonia --skill avalonia-ui-tests-nikolaygekht

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests for Avalonia UI components in this project requires knowing specific conventions: when to use [AvaloniaFact] versus [Fact], how to structure AAA-pattern tests, which assertion library to use, and how to handle headless UI limitations. This Skill encodes all those rules so generated tests match the project's established patterns. ## Core Features & Use Cases - Test attribute selection: Enforces [AvaloniaFact] for any test instantiating Avalonia controls, dialogs, or windows, and [Fact]/[Theory] for pure logic. - Control and dialog test patterns: Provides templates for value round-trips, precision transparency, constructor population from elements, explicit Save() behavior, and DialogFactory coverage. - Assertion conventions: Mandates AwesomeAssertions fluent API instead of xUnit Assert calls, with naming convention MethodUnderTest_Scenario_ExpectedBehavior. - Use Case: When adding a new EditLineDialog to the reticle editor, generate tests that verify the constructor populates controls from the element and that Save() pushes modified values back, using realistic ballistics domain data. ## Quick Start Write tests for the new MeasurementControl following the avalonia-ui-tests rules, covering initialization, value round-trip, and culture-aware parsing.

Frequently Asked Questions about avalonia-ui-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write tests for Avalonia controls in xUnit?

Use the [AvaloniaFact] attribute for any test that instantiates an Avalonia UserControl, Window, or Control subclass, and structure the test with Arrange, Act, Assert sections. Set required properties like UnitType before calling value methods, then assert with AwesomeAssertions.

When should I use AvaloniaFact versus Fact in Avalonia testing?

Use [AvaloniaFact] whenever the test creates any Avalonia control, dialog, or window, since these need the Avalonia runtime initialized. Use plain [Fact] or [Theory] only for pure logic tests such as controllers and models that never touch UI types.

Can I test UI events in Avalonia headless tests?

UI events do not fire reliably in Avalonia headless mode, so you should not test event firing directly. Test the observable behavior the event would trigger indirectly, or defer event verification to a debug application.

How do I test that a dialog saves values back to its model?

Construct the dialog with a domain element, modify its controls, and assert the element is unchanged before calling Save(). After calling Save() explicitly, assert the element properties now reflect the new control values, including initialization of previously null properties.

Why do my Avalonia control tests fail with culture-specific number formats?

Parsing depends on the CultureInfo passed to the value method, so a comma decimal separator fails under invariant culture. Write separate tests for invariant culture with dot decimals and locale-specific cultures like de-DE with comma decimals.