@@ -21,6 +21,8 @@ public class FuzzyMatcherTest
2121 private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio" ;
2222 private const string VisualStudioCode = "Visual Studio Code" ;
2323
24+ private readonly IAlphabet alphabet = null ;
25+
2426 public List < string > GetSearchStrings ( )
2527 => new List < string >
2628 {
@@ -59,7 +61,7 @@ public void MatchTest()
5961 } ;
6062
6163 var results = new List < Result > ( ) ;
62- var matcher = new StringMatcher ( ) ;
64+ var matcher = new StringMatcher ( alphabet ) ;
6365 foreach ( var str in sources )
6466 {
6567 results . Add ( new Result
@@ -81,7 +83,7 @@ public void MatchTest()
8183 public void WhenNotAllCharactersFoundInSearchString_ThenShouldReturnZeroScore ( string searchString )
8284 {
8385 var compareString = "Can have rum only in my glass" ;
84- var matcher = new StringMatcher ( ) ;
86+ var matcher = new StringMatcher ( alphabet ) ;
8587 var scoreResult = matcher . FuzzyMatch ( searchString , compareString ) . RawScore ;
8688
8789 Assert . True ( scoreResult == 0 ) ;
@@ -97,7 +99,7 @@ public void GivenQueryString_WhenAppliedPrecisionFiltering_ThenShouldReturnGreat
9799 string searchTerm )
98100 {
99101 var results = new List < Result > ( ) ;
100- var matcher = new StringMatcher ( ) ;
102+ var matcher = new StringMatcher ( alphabet ) ;
101103 foreach ( var str in GetSearchStrings ( ) )
102104 {
103105 results . Add ( new Result
@@ -147,7 +149,7 @@ public void WhenGivenQueryString_ThenShouldReturn_TheDesiredScoring(
147149 string queryString , string compareString , int expectedScore )
148150 {
149151 // When, Given
150- var matcher = new StringMatcher { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
152+ var matcher = new StringMatcher ( alphabet ) { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
151153 var rawScore = matcher . FuzzyMatch ( queryString , compareString ) . RawScore ;
152154
153155 // Should
@@ -181,7 +183,7 @@ public void WhenGivenDesiredPrecision_ThenShouldReturn_AllResultsGreaterOrEqual(
181183 bool expectedPrecisionResult )
182184 {
183185 // When
184- var matcher = new StringMatcher { UserSettingSearchPrecision = expectedPrecisionScore } ;
186+ var matcher = new StringMatcher ( alphabet ) { UserSettingSearchPrecision = expectedPrecisionScore } ;
185187
186188 // Given
187189 var matchResult = matcher . FuzzyMatch ( queryString , compareString ) ;
@@ -232,7 +234,7 @@ public void WhenGivenQuery_ShouldReturnResults_ContainingAllQuerySubstrings(
232234 bool expectedPrecisionResult )
233235 {
234236 // When
235- var matcher = new StringMatcher { UserSettingSearchPrecision = expectedPrecisionScore } ;
237+ var matcher = new StringMatcher ( alphabet ) { UserSettingSearchPrecision = expectedPrecisionScore } ;
236238
237239 // Given
238240 var matchResult = matcher . FuzzyMatch ( queryString , compareString ) ;
@@ -260,7 +262,7 @@ public void WhenGivenAQuery_Scoring_ShouldGiveMoreWeightToStartOfNewWord(
260262 string queryString , string compareString1 , string compareString2 )
261263 {
262264 // When
263- var matcher = new StringMatcher { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
265+ var matcher = new StringMatcher ( alphabet ) { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
264266
265267 // Given
266268 var compareString1Result = matcher . FuzzyMatch ( queryString , compareString1 ) ;
@@ -293,7 +295,7 @@ public void WhenGivenTwoStrings_Scoring_ShouldGiveMoreWeightToTheStringCloserToI
293295 string queryString , string compareString1 , string compareString2 )
294296 {
295297 // When
296- var matcher = new StringMatcher { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
298+ var matcher = new StringMatcher ( alphabet ) { UserSettingSearchPrecision = SearchPrecisionScore . Regular } ;
297299
298300 // Given
299301 var compareString1Result = matcher . FuzzyMatch ( queryString , compareString1 ) ;
@@ -323,7 +325,7 @@ public void WhenMultipleResults_ExactMatchingResult_ShouldHaveGreatestScore(
323325 string secondName , string secondDescription , string secondExecutableName )
324326 {
325327 // Act
326- var matcher = new StringMatcher ( ) ;
328+ var matcher = new StringMatcher ( alphabet ) ;
327329 var firstNameMatch = matcher . FuzzyMatch ( queryString , firstName ) . RawScore ;
328330 var firstDescriptionMatch = matcher . FuzzyMatch ( queryString , firstDescription ) . RawScore ;
329331 var firstExecutableNameMatch = matcher . FuzzyMatch ( queryString , firstExecutableName ) . RawScore ;
@@ -358,7 +360,7 @@ public void WhenMultipleResults_ExactMatchingResult_ShouldHaveGreatestScore(
358360 public void WhenGivenAnAcronymQuery_ShouldReturnAcronymScore ( string queryString , string compareString ,
359361 int desiredScore )
360362 {
361- var matcher = new StringMatcher ( ) ;
363+ var matcher = new StringMatcher ( alphabet ) ;
362364 var score = matcher . FuzzyMatch ( queryString , compareString ) . Score ;
363365 Assert . IsTrue ( score == desiredScore ,
364366 $@ "Query: ""{ queryString } ""
0 commit comments