3
3
using System . Diagnostics ;
4
4
using System . Linq ;
5
5
using NUnit . Framework ;
6
+ using NUnit . Framework . Legacy ;
6
7
using Flow . Launcher . Infrastructure ;
7
8
using Flow . Launcher . Plugin ;
8
9
using Flow . Launcher . Plugin . SharedModels ;
@@ -21,8 +22,8 @@ public class FuzzyMatcherTest
21
22
private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio" ;
22
23
private const string VisualStudioCode = "Visual Studio Code" ;
23
24
24
- public List < string > GetSearchStrings ( )
25
- => new List < string >
25
+ public static List < string > GetSearchStrings ( )
26
+ => new ( )
26
27
{
27
28
Chrome ,
28
29
"Choose which programs you want Windows to use for activities like web browsing, editing photos, sending e-mail, and playing music." ,
@@ -34,7 +35,7 @@ public List<string> GetSearchStrings()
34
35
OneOneOneOne
35
36
} ;
36
37
37
- public List < int > GetPrecisionScores ( )
38
+ public static List < int > GetPrecisionScores ( )
38
39
{
39
40
var listToReturn = new List < int > ( ) ;
40
41
@@ -71,10 +72,10 @@ public void MatchTest()
71
72
72
73
results = results . Where ( x => x . Score > 0 ) . OrderByDescending ( x => x . Score ) . ToList ( ) ;
73
74
74
- Assert . IsTrue ( results . Count == 3 ) ;
75
- Assert . IsTrue ( results [ 0 ] . Title == "Inste" ) ;
76
- Assert . IsTrue ( results [ 1 ] . Title == "Install Package" ) ;
77
- Assert . IsTrue ( results [ 2 ] . Title == "file open in browser-test" ) ;
75
+ ClassicAssert . IsTrue ( results . Count == 3 ) ;
76
+ ClassicAssert . IsTrue ( results [ 0 ] . Title == "Inste" ) ;
77
+ ClassicAssert . IsTrue ( results [ 1 ] . Title == "Install Package" ) ;
78
+ ClassicAssert . IsTrue ( results [ 2 ] . Title == "file open in browser-test" ) ;
78
79
}
79
80
80
81
[ TestCase ( "Chrome" ) ]
@@ -84,7 +85,7 @@ public void WhenNotAllCharactersFoundInSearchString_ThenShouldReturnZeroScore(st
84
85
var matcher = new StringMatcher ( ) ;
85
86
var scoreResult = matcher . FuzzyMatch ( searchString , compareString ) . RawScore ;
86
87
87
- Assert . True ( scoreResult == 0 ) ;
88
+ ClassicAssert . True ( scoreResult == 0 ) ;
88
89
}
89
90
90
91
[ TestCase ( "chr" ) ]
@@ -125,7 +126,7 @@ public void GivenQueryString_WhenAppliedPrecisionFiltering_ThenShouldReturnGreat
125
126
Debug . WriteLine ( "###############################################" ) ;
126
127
Debug . WriteLine ( "" ) ;
127
128
128
- Assert . IsFalse ( filteredResult . Any ( x => x . Score < precisionScore ) ) ;
129
+ ClassicAssert . IsFalse ( filteredResult . Any ( x => x . Score < precisionScore ) ) ;
129
130
}
130
131
}
131
132
@@ -151,7 +152,7 @@ public void WhenGivenQueryString_ThenShouldReturn_TheDesiredScoring(
151
152
var rawScore = matcher . FuzzyMatch ( queryString , compareString ) . RawScore ;
152
153
153
154
// Should
154
- Assert . AreEqual ( expectedScore , rawScore ,
155
+ ClassicAssert . AreEqual ( expectedScore , rawScore ,
155
156
$ "Expected score for compare string '{ compareString } ': { expectedScore } , Actual: { rawScore } ") ;
156
157
}
157
158
@@ -190,12 +191,12 @@ public void WhenGivenDesiredPrecision_ThenShouldReturn_AllResultsGreaterOrEqual(
190
191
Debug . WriteLine ( "###############################################" ) ;
191
192
Debug . WriteLine ( $ "QueryString: { queryString } CompareString: { compareString } ") ;
192
193
Debug . WriteLine (
193
- $ "RAW SCORE: { matchResult . RawScore . ToString ( ) } , PrecisionLevelSetAt: { expectedPrecisionScore } ({ ( int ) expectedPrecisionScore } )") ;
194
+ $ "RAW SCORE: { matchResult . RawScore } , PrecisionLevelSetAt: { expectedPrecisionScore } ({ ( int ) expectedPrecisionScore } )") ;
194
195
Debug . WriteLine ( "###############################################" ) ;
195
196
Debug . WriteLine ( "" ) ;
196
197
197
198
// Should
198
- Assert . AreEqual ( expectedPrecisionResult , matchResult . IsSearchPrecisionScoreMet ( ) ,
199
+ ClassicAssert . AreEqual ( expectedPrecisionResult , matchResult . IsSearchPrecisionScoreMet ( ) ,
199
200
$ "Query: { queryString } { Environment . NewLine } " +
200
201
$ "Compare: { compareString } { Environment . NewLine } " +
201
202
$ "Raw Score: { matchResult . RawScore } { Environment . NewLine } " +
@@ -241,12 +242,12 @@ public void WhenGivenQuery_ShouldReturnResults_ContainingAllQuerySubstrings(
241
242
Debug . WriteLine ( "###############################################" ) ;
242
243
Debug . WriteLine ( $ "QueryString: { queryString } CompareString: { compareString } ") ;
243
244
Debug . WriteLine (
244
- $ "RAW SCORE: { matchResult . RawScore . ToString ( ) } , PrecisionLevelSetAt: { expectedPrecisionScore } ({ ( int ) expectedPrecisionScore } )") ;
245
+ $ "RAW SCORE: { matchResult . RawScore } , PrecisionLevelSetAt: { expectedPrecisionScore } ({ ( int ) expectedPrecisionScore } )") ;
245
246
Debug . WriteLine ( "###############################################" ) ;
246
247
Debug . WriteLine ( "" ) ;
247
248
248
249
// Should
249
- Assert . AreEqual ( expectedPrecisionResult , matchResult . IsSearchPrecisionScoreMet ( ) ,
250
+ ClassicAssert . AreEqual ( expectedPrecisionResult , matchResult . IsSearchPrecisionScoreMet ( ) ,
250
251
$ "Query:{ queryString } { Environment . NewLine } " +
251
252
$ "Compare:{ compareString } { Environment . NewLine } " +
252
253
$ "Raw Score: { matchResult . RawScore } { Environment . NewLine } " +
@@ -277,7 +278,7 @@ public void WhenGivenAQuery_Scoring_ShouldGiveMoreWeightToStartOfNewWord(
277
278
Debug . WriteLine ( "" ) ;
278
279
279
280
// Should
280
- Assert . True ( compareString1Result . Score > compareString2Result . Score ,
281
+ ClassicAssert . True ( compareString1Result . Score > compareString2Result . Score ,
281
282
$ "Query: \" { queryString } \" { Environment . NewLine } " +
282
283
$ "CompareString1: \" { compareString1 } \" , Score: { compareString1Result . Score } { Environment . NewLine } " +
283
284
$ "Should be greater than{ Environment . NewLine } " +
@@ -310,7 +311,7 @@ public void WhenGivenTwoStrings_Scoring_ShouldGiveMoreWeightToTheStringCloserToI
310
311
Debug . WriteLine ( "" ) ;
311
312
312
313
// Should
313
- Assert . True ( compareString1Result . Score > compareString2Result . Score ,
314
+ ClassicAssert . True ( compareString1Result . Score > compareString2Result . Score ,
314
315
$ "Query: \" { queryString } \" { Environment . NewLine } " +
315
316
$ "CompareString1: \" { compareString1 } \" , Score: { compareString1Result . Score } { Environment . NewLine } " +
316
317
$ "Should be greater than{ Environment . NewLine } " +
@@ -336,7 +337,7 @@ public void WhenMultipleResults_ExactMatchingResult_ShouldHaveGreatestScore(
336
337
var secondScore = new [ ] { secondNameMatch , secondDescriptionMatch , secondExecutableNameMatch } . Max ( ) ;
337
338
338
339
// Assert
339
- Assert . IsTrue ( firstScore > secondScore ,
340
+ ClassicAssert . IsTrue ( firstScore > secondScore ,
340
341
$ "Query: \" { queryString } \" { Environment . NewLine } " +
341
342
$ "Name of first: \" { firstName } \" , Final Score: { firstScore } { Environment . NewLine } " +
342
343
$ "Should be greater than{ Environment . NewLine } " +
@@ -360,7 +361,7 @@ public void WhenGivenAnAcronymQuery_ShouldReturnAcronymScore(string queryString,
360
361
{
361
362
var matcher = new StringMatcher ( ) ;
362
363
var score = matcher . FuzzyMatch ( queryString , compareString ) . Score ;
363
- Assert . IsTrue ( score == desiredScore ,
364
+ ClassicAssert . IsTrue ( score == desiredScore ,
364
365
$@ "Query: ""{ queryString } ""
365
366
CompareString: ""{ compareString } ""
366
367
Score: { score }
0 commit comments