Skip to content

Commit b481425

Browse files
author
tznind
committed
Fix subclasses of TextValidateField (TimeEditor and DateEditor) getting given a TextRegexProvider (invalid cast).
1 parent b7b17cb commit b481425

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/ViewFactory.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ public static T Create<T>(int? width = null, int? height = null, string? text =
189189
tv.AddEmptyTab( "Tab2" );
190190
SetDefaultDimensions( newView, width ?? 50, height ?? 5 );
191191
break;
192+
case TimeEditor te:
193+
SetDefaultDimensions(newView, width ?? 10, height ?? 1);
194+
break;
195+
case DateEditor de:
196+
SetDefaultDimensions(newView, width ?? 10, height ?? 1);
197+
break;
192198
case TextValidateField tvf:
193199
tvf.Provider = new TextRegexProvider( ".*" );
194200
tvf.Text = text ?? "Heya";

tests/ViewFactoryTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ private static IEnumerable<TestCaseData> Create_And_CreateT_Type_Provider
2222
.Select(Tests.PickFirstTTypeForGenerics)
2323
.Select(
2424
static t => new TestCaseData(
25-
RuntimeHelpers.GetUninitializedObject( t )
26-
) ); }
25+
RuntimeHelpers.GetUninitializedObject( t )
26+
)
27+
.SetName($"Create_And_CreateT_ReturnExpectedType<{t.Name}>")
28+
); }
2729
}
2830

2931
private static MenuBarItem[] ViewFactory_DefaultMenuBarItems => ViewFactory.DefaultMenuBarItems;

0 commit comments

Comments
 (0)