Phase 2: Update examples with attributes and add test infrastructure

- Updated Example, FluentExample, and RunnableWrapperExample with example attributes
- Added support for driver name detection from test context in examples
- Created ExampleTests class in UnitTestsParallelizable with tests for:
  - Example metadata validation
  - Out-of-process execution
  - In-process execution
  - Context serialization
- Examples now properly detect and use FakeDriver from test context
- Tests pass for metadata validation and serialization

Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-01 22:06:23 +00:00
parent ea5eabf6e3
commit cd392456ca
4 changed files with 211 additions and 3 deletions

View File

@@ -2,11 +2,28 @@
using Terminal.Gui.App;
using Terminal.Gui.Drawing;
using Terminal.Gui.Examples;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;
[assembly: ExampleMetadata ("Fluent API Example", "Demonstrates the fluent IApplication API with IRunnable pattern")]
[assembly: ExampleCategory ("API Patterns")]
[assembly: ExampleCategory ("Controls")]
[assembly: ExampleDemoKeyStrokes (KeyStrokes = new [] { "CursorDown", "CursorDown", "CursorRight", "Enter" }, Order = 1)]
[assembly: ExampleDemoKeyStrokes (KeyStrokes = new [] { "Esc" }, DelayMs = 100, Order = 2)]
// Check for test context to determine driver
string? contextJson = Environment.GetEnvironmentVariable (ExampleContext.EnvironmentVariableName);
string? driverName = null;
if (!string.IsNullOrEmpty (contextJson))
{
ExampleContext? context = ExampleContext.FromJson (contextJson);
driverName = context?.DriverName;
}
IApplication? app = Application.Create ()
.Init ()
.Init (driverName)
.Run<ColorPickerView> ();
// Run the application with fluent API - automatically creates, runs, and disposes the runnable