Greenfield skeleton for a parser desktop app. The domain is deliberately a placeholder — IParser<TIn,TOut> plus two sample parsers — so the shell is runnable and verifiable end to end before real logic lands. Layers run one way: Core (no Avalonia, no IO) <- Infrastructure <- UI <- Desktop. UI is a class library rather than the exe so headless tests build real views without dragging in Program.cs, Serilog or the container. Adaptive layout is built from what Avalonia actually offers, since it has no AdaptiveTrigger or media queries: ResponsiveLayout observes Visual.Bounds and projects a breakpoint onto both an attached property and :compact/:medium/ :expanded pseudoclasses, with 24px hysteresis so dragging a window edge cannot make the layout flap. Pane state lives in the view model because a style setter loses to a local value permanently; styles own only the visual variance. Stack notes worth remembering: Avalonia.ReactiveUI is deprecated in favour of ReactiveUI.Avalonia, and ReactiveUI 24 runs on the Primitives engine (RxVoid, ISequencer, Signal<T>) and no longer self-initialises. Avalonia.Headless.XUnit 12.x requires xUnit v3. InvariantGlobalization must stay false or Semi.Avalonia throws in its static constructor. 102 tests across three projects, including headless guards for the two failures that are otherwise completely silent: a stylesheet whose selectors match nothing, and a light palette too low-contrast for cards to read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using AvParser.Core.Parsing;
|
|
using AvParser.Core.Parsing.Samples;
|
|
|
|
namespace AvParser.Core.Tests;
|
|
|
|
public class ParserCatalogTests
|
|
{
|
|
private static IParserCatalog Catalog() => new ParserCatalog([new KeyValueTextParser(), new DelimitedTextParser()]);
|
|
|
|
[Fact]
|
|
public void Orders_parsers_by_display_name_regardless_of_registration_order() =>
|
|
Catalog().Parsers.Select(p => p.Id).ShouldBe(["delimited", "key-value"]);
|
|
|
|
[Fact]
|
|
public void Finds_a_parser_by_id_ignoring_case() => Catalog().Find("KEY-VALUE")!.Id.ShouldBe("key-value");
|
|
|
|
[Fact]
|
|
public void Returns_null_for_an_unknown_id() => Catalog().Find("nope").ShouldBeNull();
|
|
|
|
[Fact]
|
|
public void Falls_back_to_the_default_for_an_unknown_id()
|
|
{
|
|
var catalog = Catalog();
|
|
|
|
catalog.FindOrDefault("nope").ShouldBeSameAs(catalog.DefaultParser);
|
|
catalog.FindOrDefault(null).ShouldBeSameAs(catalog.DefaultParser);
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejects_an_empty_registration() => Should.Throw<ArgumentException>(() => new ParserCatalog([]));
|
|
|
|
[Fact]
|
|
public void Rejects_duplicate_ids() =>
|
|
Should
|
|
.Throw<ArgumentException>(() => new ParserCatalog([new DelimitedTextParser(), new DelimitedTextParser()]))
|
|
.Message.ShouldContain("Duplicate");
|
|
}
|