mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user