Skip to content

Commit 8e43277

Browse files
committed
Add test infrastructure for LINE and CELL mode testing
Add helper methods to TestWindowSystemBuilder: - CreateTestSystemWithLineMode() - creates system with LINE mode - CreateTestSystemWithCellMode() - creates system with CELL mode - Update CreateTestSystem() to use new default (Smart mode) These helpers enable explicit mode testing and allow tests to verify both LINE and CELL mode behavior independently.
1 parent 7634c1e commit 8e43277

1 file changed

Lines changed: 82 additions & 2 deletions

File tree

SharpConsoleUI.Tests/Infrastructure/TestWindowSystemBuilder.cs

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ public static class TestWindowSystemBuilder
2525
/// <returns>A configured ConsoleWindowSystem instance ready for testing.</returns>
2626
public static ConsoleWindowSystem CreateTestSystem(Action<ConsoleWindowSystemOptions>? configure = null)
2727
{
28+
// Disable status bars by default in tests to isolate core rendering logic
29+
var statusBarOptions = new Configuration.StatusBarOptions(
30+
ShowTopStatus: false,
31+
ShowBottomStatus: false,
32+
ShowTaskBar: false,
33+
ShowStartButton: false
34+
);
35+
2836
var options = new ConsoleWindowSystemOptions(
2937
EnableDiagnostics: true,
3038
DiagnosticsRetainFrames: 10,
3139
DiagnosticsLayers: DiagnosticsLayers.All,
3240
EnableQualityAnalysis: true,
3341
EnableFrameRateLimiting: false,
34-
EnablePerformanceMetrics: false
42+
EnablePerformanceMetrics: false,
43+
StatusBarOptions: statusBarOptions
3544
);
3645

3746
// Allow caller to customize options
@@ -57,13 +66,22 @@ public static ConsoleWindowSystem CreateTestSystem(int width, int height)
5766
{
5867
var mockDriver = new MockConsoleDriver(width, height);
5968

69+
// Disable status bars by default in tests to isolate core rendering logic
70+
var statusBarOptions = new Configuration.StatusBarOptions(
71+
ShowTopStatus: false,
72+
ShowBottomStatus: false,
73+
ShowTaskBar: false,
74+
ShowStartButton: false
75+
);
76+
6077
var options = new ConsoleWindowSystemOptions(
6178
EnableDiagnostics: true,
6279
DiagnosticsRetainFrames: 10,
6380
DiagnosticsLayers: DiagnosticsLayers.All,
6481
EnableQualityAnalysis: true,
6582
EnableFrameRateLimiting: false,
66-
EnablePerformanceMetrics: false
83+
EnablePerformanceMetrics: false,
84+
StatusBarOptions: statusBarOptions
6785
);
6886

6987
return new ConsoleWindowSystem(mockDriver, options: options);
@@ -84,4 +102,66 @@ public static ConsoleWindowSystem CreateTestSystemWithoutDiagnostics()
84102

85103
return new ConsoleWindowSystem(mockDriver, options: options);
86104
}
105+
106+
/// <summary>
107+
/// Creates a test window system with line-level dirty tracking mode.
108+
/// </summary>
109+
public static ConsoleWindowSystem CreateTestSystemWithLineMode()
110+
{
111+
// Disable status bars by default in tests to isolate core rendering logic
112+
var statusBarOptions = new Configuration.StatusBarOptions(
113+
ShowTopStatus: false,
114+
ShowBottomStatus: false,
115+
ShowTaskBar: false,
116+
ShowStartButton: false
117+
);
118+
119+
var options = new ConsoleWindowSystemOptions(
120+
EnableDiagnostics: true,
121+
DiagnosticsRetainFrames: 10,
122+
DiagnosticsLayers: DiagnosticsLayers.All,
123+
EnableQualityAnalysis: true,
124+
EnableFrameRateLimiting: false,
125+
EnablePerformanceMetrics: false,
126+
StatusBarOptions: statusBarOptions,
127+
DirtyTrackingMode: Configuration.DirtyTrackingMode.Line // LINE MODE
128+
);
129+
130+
// Create mock console driver
131+
var mockDriver = new MockConsoleDriver();
132+
133+
// Create window system
134+
return new ConsoleWindowSystem(mockDriver, options: options);
135+
}
136+
137+
/// <summary>
138+
/// Creates a test window system with cell-level dirty tracking mode.
139+
/// </summary>
140+
public static ConsoleWindowSystem CreateTestSystemWithCellMode()
141+
{
142+
// Disable status bars by default in tests to isolate core rendering logic
143+
var statusBarOptions = new Configuration.StatusBarOptions(
144+
ShowTopStatus: false,
145+
ShowBottomStatus: false,
146+
ShowTaskBar: false,
147+
ShowStartButton: false
148+
);
149+
150+
var options = new ConsoleWindowSystemOptions(
151+
EnableDiagnostics: true,
152+
DiagnosticsRetainFrames: 10,
153+
DiagnosticsLayers: DiagnosticsLayers.All,
154+
EnableQualityAnalysis: true,
155+
EnableFrameRateLimiting: false,
156+
EnablePerformanceMetrics: false,
157+
StatusBarOptions: statusBarOptions,
158+
DirtyTrackingMode: Configuration.DirtyTrackingMode.Cell // CELL MODE
159+
);
160+
161+
// Create mock console driver
162+
var mockDriver = new MockConsoleDriver();
163+
164+
// Create window system
165+
return new ConsoleWindowSystem(mockDriver, options: options);
166+
}
87167
}

0 commit comments

Comments
 (0)