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

@@ -5,14 +5,31 @@
using Terminal.Gui.App;
using Terminal.Gui.Configuration;
using Terminal.Gui.Examples;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;
[assembly: ExampleMetadata ("Simple Example", "A basic login form demonstrating Terminal.Gui fundamentals")]
[assembly: ExampleCategory ("Getting Started")]
[assembly: ExampleDemoKeyStrokes (KeyStrokes = new [] { "a", "d", "m", "i", "n", "Tab", "p", "a", "s", "s", "w", "o", "r", "d", "Enter" }, Order = 1)]
[assembly: ExampleDemoKeyStrokes (KeyStrokes = new [] { "Enter" }, DelayMs = 500, Order = 2)]
[assembly: ExampleDemoKeyStrokes (KeyStrokes = new [] { "Esc" }, DelayMs = 100, Order = 3)]
// Override the default configuration for the application to use the Light theme
ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }""";
ConfigurationManager.Enable (ConfigLocations.All);
IApplication app = Application.Create ();
// 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 (driverName);
app.Run<ExampleWindow> ();