private static void GivenIntegerType_ExpectPositive(IFuzzyMatcher <MyTargetType, string> matcher) { var match = matcher.FindNearest(One); Assert.AreEqual(0, match.Distance); Assert.AreEqual(1, match.Element.Id); }
private static void GivenEmptyQuery_ExpectEmptyMatch(IFuzzyMatcher <string, string> matcher) { var match = matcher.FindNearest(string.Empty); Assert.AreEqual(string.Empty, match.Element); Assert.AreEqual(0, match.Distance); }
public void GivenHugeTarget_ExpectFarMatch() { string[] target = new string[] { "This is clearly not a number. It doesn't even sound like a number." }; IFuzzyMatcher <string, string>[] matchers = new IFuzzyMatcher <string, string>[] { new StringFuzzyMatcher <string>(target), new EnPhoneticFuzzyMatcher <string>(target), new EnHybridFuzzyMatcher <string>(target, PhoneticWeightPercentage), }; foreach (var matcher in matchers) { var match = matcher.FindNearest(One); Assert.IsTrue(match.Distance > 1, $"{matcher.GetType().Name} failed with distance={match.Distance}"); } }
private static void GivenNormalizedMatcher_ExpectLessDistanceThanRegularMatcher <Extraction>(IFuzzyMatcher <string, string> normalizedMatcher, IFuzzyMatcher <string, Extraction> regularMatcher, Func <string, Extraction> queryToExtraction) { string query = "ten"; var normalizedMatch = normalizedMatcher.FindNearest(query); var regularMatch = regularMatcher.FindNearest(queryToExtraction(query)); Assert.AreEqual(normalizedMatch.Element, regularMatch.Element); Assert.IsTrue(normalizedMatch.Distance < regularMatch.Distance); }