- StackExtensionsTests.cs - 10 tests for Stack extensions
- TabTests.cs - 1 constructor test
- AnsiMouseParserTests.cs - 14 ANSI mouse parsing tests
- Dim.FillTests.cs - 1 test (merged with existing)
Refactored Tests (93 tests - Using local FakeDriver)
TextFormatterTests.cs - 10 Draw methods refactored:
- Draw_Horizontal_Centered - 11 test cases
- Draw_Horizontal_Justified - 11 test cases
- Draw_Horizontal_Left - 9 test cases
- Draw_Horizontal_Right - 8 test cases
- Draw_Horizontal_RightLeft_BottomTop - 11 test cases
- Draw_Horizontal_RightLeft_TopBottom - 11 test cases
- Draw_Vertical_BottomTop_LeftRight - 11 test cases
- Draw_Vertical_BottomTop_RightLeft - 11 test cases
- Draw_Vertical_TopBottom_LeftRight - 3 test cases
- Draw_Vertical_TopBottom_LeftRight_Top - 8 test cases
Refactoring Pattern Used:
public void TestMethod (params)
{
// Create local driver instance
var factory = new FakeDriverFactory ();
var driver = factory.Create ();
driver.SetBufferSize (width, height);
// Pass driver explicitly to methods
textFormatter.Draw (rect, attr1, attr2, driver: driver);
// Extract and assert results
string actual = GetDriverContents (driver, width, height);
Assert.Equal (expected, actual);
}
Remaining Work
TextFormatterTests.cs (8 tests remaining)
Status Analysis:
Draw_Vertical_TopBottom_LeftRight_Middle
- Can migrate: Yes, with helper enhancement
- Complexity: Returns Rectangle, validates Y position
- Action needed: Enhance helper to return position info
Draw_Vertical_Bottom_Horizontal_Right
- Can migrate: Yes, with helper enhancement
- Complexity: Returns Rectangle, validates Y position
- Action needed: Same as above
Draw_Text_Justification
- Can migrate: Yes
- Complexity: Multi-parameter test
- Action needed: Standard refactoring pattern
Justify_Horizontal
- Can migrate: Yes
- Complexity: Standard Draw test
- Action needed: Standard refactoring pattern
FillRemaining_True_False
- Can migrate: Need investigation
- Complexity: May modify state beyond driver
- Action needed: Review implementation
UICatalog_AboutBox_Text
- Can migrate: Need investigation
- Complexity: May load external resources
- Action needed: Review dependencies
FormatAndGetSize_Returns_Correct_Size
- Can migrate: Need investigation
- Complexity: May require specific driver capabilities
- Action needed: Review method signature
FormatAndGetSize_WordWrap_False_Returns_Correct_Size
- Can migrate: Need investigation
- Complexity: May require specific driver capabilities
- Action needed: Review method signature
Other Files with SetupFakeDriver (34 files)
Files requiring systematic review:
- CursorTests.cs
- FakeDriverTests.cs
- LineCanvasTests.cs
- RulerTests.cs
- AdornmentTests.cs
- BorderTests.cs
- MarginTests.cs
- PaddingTests.cs
- ShadowStyleTests.cs
- AllViewsDrawTests.cs
- ClearViewportTests.cs
- ClipTests.cs
- DrawTests.cs
- TransparentTests.cs
- LayoutTests.cs
- Pos.CombineTests.cs
- NavigationTests.cs
- TextTests.cs
- AllViewsTests.cs
- ButtonTests.cs
- CheckBoxTests.cs
- ColorPickerTests.cs
- DateFieldTests.cs
- LabelTests.cs
- RadioGroupTests.cs
- ScrollBarTests.cs
- ScrollSliderTests.cs
- TabViewTests.cs
- TableViewTests.cs
- TextFieldTests.cs
- ToplevelTests.cs
- TreeTableSourceTests.cs
- TreeViewTests.cs
- SetupFakeDriverAttribute.cs (infrastructure)
For each file, need to determine:
- Which tests use methods that accept driver parameters → Migratable
- Which tests require View hierarchy/Application context → Likely non-migratable
- Which tests modify global state → Non-migratable
Non-Migratable Tests (TBD - Requires detailed analysis)
Common reasons tests CANNOT be migrated:
- Requires Application.Init() - Tests that need event loop, application context
- Tests View hierarchy - Tests that rely on View parent/child relationships requiring Application
- Modifies ConfigurationManager - Tests that change global configuration state
- Requires specific driver features - Tests that depend on platform-specific driver behavior
- Integration tests - Tests validating multiple components together with Application context
Recommendations
- Complete TextFormatterTests migration - 4-6 tests clearly migratable
- Systematic file-by-file review - Categorize each of the 34 remaining files
- Document non-migratable - For each test that cannot be migrated, document specific reason
- Consider test refactoring - Some integration tests could be split into unit + integration parts
- Update guidelines - Document patterns for writing parallelizable tests
Technical Notes
Why Some Tests Must Remain in UnitTests
Many tests in UnitTests are correctly placed integration tests that should NOT be parallelized:
- They test View behavior within Application context
- They validate event handling through Application.MainLoop
- They test ConfigurationManager integration
- They verify driver-specific platform behavior
- They test complex component interactions
These are valuable integration tests and should remain in UnitTests.
Pattern for Future Test Development
New tests should default to UnitTests.Parallelizable unless they:
- Require Application.Init()
- Test View hierarchy interactions
- Modify global state (ConfigurationManager, Application properties)
- Are explicitly integration tests