File tree Expand file tree Collapse file tree 3 files changed +60
-60
lines changed
src/Tests/Spectre.Console.Tests/Unit/Prompts Expand file tree Collapse file tree 3 files changed +60
-60
lines changed Original file line number Diff line number Diff line change @@ -2,25 +2,6 @@ namespace Spectre.Console.Tests.Unit;
2
2
3
3
public sealed class MultiSelectionPromptTests
4
4
{
5
- private class CustomItem
6
- {
7
- public int X { get ; set ; }
8
- public int Y { get ; set ; }
9
-
10
- public class Comparer : IEqualityComparer < CustomItem >
11
- {
12
- public bool Equals ( CustomItem x , CustomItem y )
13
- {
14
- return x . X == y . X && x . Y == y . Y ;
15
- }
16
-
17
- public int GetHashCode ( CustomItem obj )
18
- {
19
- throw new NotSupportedException ( ) ;
20
- }
21
- }
22
- }
23
-
24
5
[ Fact ]
25
6
public void Should_Not_Mark_Item_As_Selected_By_Default ( )
26
7
{
@@ -147,3 +128,22 @@ public void Should_Throw_When_Getting_Parents_Of_Non_Existing_Node()
147
128
action . ShouldThrow < ArgumentOutOfRangeException > ( ) ;
148
129
}
149
130
}
131
+
132
+ file sealed class CustomItem
133
+ {
134
+ public int X { get ; set ; }
135
+ public int Y { get ; set ; }
136
+
137
+ public class Comparer : IEqualityComparer < CustomItem >
138
+ {
139
+ public bool Equals ( CustomItem x , CustomItem y )
140
+ {
141
+ return x . X == y . X && x . Y == y . Y ;
142
+ }
143
+
144
+ public int GetHashCode ( CustomItem obj )
145
+ {
146
+ throw new NotSupportedException ( ) ;
147
+ }
148
+ }
149
+ }
Original file line number Diff line number Diff line change @@ -85,4 +85,45 @@ public void Should_Highlight_Search_Term()
85
85
// Then
86
86
console . Output . ShouldContain ( $ "{ ESC } [38;5;12m> Item { ESC } [0m{ ESC } [1;38;5;12;48;5;11m1{ ESC } [0m") ;
87
87
}
88
+
89
+ [ Fact ]
90
+ public void Should_Search_In_Remapped_Result ( )
91
+ {
92
+ // Given
93
+ var console = new TestConsole ( ) ;
94
+ console . Profile . Capabilities . Interactive = true ;
95
+ console . EmitAnsiSequences ( ) ;
96
+ console . Input . PushText ( "2" ) ;
97
+ console . Input . PushKey ( ConsoleKey . Enter ) ;
98
+
99
+ var choices = new List < CustomSelectionItem >
100
+ {
101
+ new ( 33 , "Item 1" ) ,
102
+ new ( 34 , "Item 2" ) ,
103
+ } ;
104
+
105
+ var prompt = new SelectionPrompt < CustomSelectionItem > ( )
106
+ . Title ( "Select one" )
107
+ . EnableSearch ( )
108
+ . UseConverter ( o => o . Name )
109
+ . AddChoices ( choices ) ;
110
+
111
+ // When
112
+ var selection = prompt . Show ( console ) ;
113
+
114
+ // Then
115
+ selection . ShouldBe ( choices [ 1 ] ) ;
116
+ }
117
+ }
118
+
119
+ file sealed class CustomSelectionItem
120
+ {
121
+ public int Value { get ; }
122
+ public string Name { get ; }
123
+
124
+ public CustomSelectionItem ( int value , string name )
125
+ {
126
+ Value = value ;
127
+ Name = name ?? throw new ArgumentNullException ( nameof ( name ) ) ;
128
+ }
88
129
}
Original file line number Diff line number Diff line change @@ -410,45 +410,4 @@ public Task Uses_the_specified_choices_style()
410
410
// Then
411
411
return Verifier . Verify ( console . Output ) ;
412
412
}
413
-
414
- [ Fact ]
415
- public void Should_Search_In_Remapped_Result ( )
416
- {
417
- // Given
418
- var console = new TestConsole ( ) ;
419
- console . Profile . Capabilities . Interactive = true ;
420
- console . EmitAnsiSequences ( ) ;
421
- console . Input . PushText ( "2" ) ;
422
- console . Input . PushKey ( ConsoleKey . Enter ) ;
423
-
424
- var choices = new List < CustomSelectionItem >
425
- {
426
- new ( 33 , "Item 1" ) ,
427
- new ( 34 , "Item 2" ) ,
428
- } ;
429
-
430
- var prompt = new SelectionPrompt < CustomSelectionItem > ( )
431
- . Title ( "Select one" )
432
- . EnableSearch ( )
433
- . UseConverter ( o => o . Name )
434
- . AddChoices ( choices ) ;
435
-
436
- // When
437
- var selection = prompt . Show ( console ) ;
438
-
439
- // Then
440
- selection . ShouldBe ( choices [ 1 ] ) ;
441
- }
442
- }
443
-
444
- file sealed class CustomSelectionItem
445
- {
446
- public int Value { get ; }
447
- public string Name { get ; }
448
-
449
- public CustomSelectionItem ( int value , string name )
450
- {
451
- Value = value ;
452
- Name = name ?? throw new ArgumentNullException ( nameof ( name ) ) ;
453
- }
454
413
}
You can’t perform that action at this time.
0 commit comments