@@ -129,14 +129,20 @@ public void GivenQueryString_WhenAppliedPrecisionFiltering_ThenShouldReturnGreat
129
129
}
130
130
}
131
131
132
+
133
+ /// <summary>
134
+ /// These are standard match scenarios
135
+ /// The intention of this test is provide a bench mark for how much the score has increased from a change.
136
+ /// Usually the increase in scoring should not be drastic, increase of less than 10 is acceptable.
137
+ /// </summary>
132
138
[ TestCase ( Chrome , Chrome , 157 ) ]
133
- [ TestCase ( Chrome , LastIsChrome , 147 ) ]
139
+ [ TestCase ( Chrome , LastIsChrome , 145 ) ]
134
140
[ TestCase ( "chro" , HelpCureHopeRaiseOnMindEntityChrome , 50 ) ]
135
141
[ TestCase ( "chr" , HelpCureHopeRaiseOnMindEntityChrome , 30 ) ]
136
142
[ TestCase ( Chrome , UninstallOrChangeProgramsOnYourComputer , 21 ) ]
137
143
[ TestCase ( Chrome , CandyCrushSagaFromKing , 0 ) ]
138
- [ TestCase ( "sql" , MicrosoftSqlServerManagementStudio , 110 ) ]
139
- [ TestCase ( "sql manag" , MicrosoftSqlServerManagementStudio , 121 ) ] //double spacing intended
144
+ [ TestCase ( "sql" , MicrosoftSqlServerManagementStudio , 109 ) ]
145
+ [ TestCase ( "sql manag" , MicrosoftSqlServerManagementStudio , 120 ) ] //double spacing intended
140
146
public void WhenGivenQueryString_ThenShouldReturn_TheDesiredScoring (
141
147
string queryString , string compareString , int expectedScore )
142
148
{
@@ -275,7 +281,40 @@ public void WhenGivenAQuery_Scoring_ShouldGiveMoreWeightToStartOfNewWord(
275
281
$ "Query: \" { queryString } \" { Environment . NewLine } " +
276
282
$ "CompareString1: \" { compareString1 } \" , Score: { compareString1Result . Score } { Environment . NewLine } " +
277
283
$ "Should be greater than{ Environment . NewLine } " +
278
- $ "CompareString2: \" { compareString2 } \" , Score: { compareString1Result . Score } { Environment . NewLine } ") ;
284
+ $ "CompareString2: \" { compareString2 } \" , Score: { compareString2Result . Score } { Environment . NewLine } ") ;
285
+ }
286
+
287
+ [ TestCase ( "red" , "red colour" , "metro red" ) ]
288
+ [ TestCase ( "red" , "this red colour" , "this colour red" ) ]
289
+ [ TestCase ( "red" , "this red colour" , "this colour is very red" ) ]
290
+ [ TestCase ( "red" , "this red colour" , "this colour is surprisingly super awesome red and cool" ) ]
291
+ [ TestCase ( "red" , "this colour is surprisingly super red very and cool" , "this colour is surprisingly super very red and cool" ) ]
292
+ public void WhenGivenTwoStrings_Scoring_ShouldGiveMoreWeightToTheStringCloserToIndexZero (
293
+ string queryString , string compareString1 , string compareString2 )
294
+ {
295
+ // When
296
+ var matcher = new StringMatcher { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
297
+
298
+ // Given
299
+ var compareString1Result = matcher . FuzzyMatch ( queryString , compareString1 ) ;
300
+ var compareString2Result = matcher . FuzzyMatch ( queryString , compareString2 ) ;
301
+
302
+ Debug . WriteLine ( "" ) ;
303
+ Debug . WriteLine ( "###############################################" ) ;
304
+ Debug . WriteLine ( $ "QueryString: \" { queryString } \" { Environment . NewLine } ") ;
305
+ Debug . WriteLine (
306
+ $ "CompareString1: \" { compareString1 } \" , Score: { compareString1Result . Score } { Environment . NewLine } ") ;
307
+ Debug . WriteLine (
308
+ $ "CompareString2: \" { compareString2 } \" , Score: { compareString2Result . Score } { Environment . NewLine } ") ;
309
+ Debug . WriteLine ( "###############################################" ) ;
310
+ Debug . WriteLine ( "" ) ;
311
+
312
+ // Should
313
+ Assert . True ( compareString1Result . Score > compareString2Result . Score ,
314
+ $ "Query: \" { queryString } \" { Environment . NewLine } " +
315
+ $ "CompareString1: \" { compareString1 } \" , Score: { compareString1Result . Score } { Environment . NewLine } " +
316
+ $ "Should be greater than{ Environment . NewLine } " +
317
+ $ "CompareString2: \" { compareString2 } \" , Score: { compareString2Result . Score } { Environment . NewLine } ") ;
279
318
}
280
319
281
320
[ TestCase ( "vim" , "Vim" , "ignoreDescription" , "ignore.exe" , "Vim Diff" , "ignoreDescription" , "ignore.exe" ) ]
0 commit comments