private static void AssertClosestMatches(IEnumerable <string> dictionary, string term, int maxEditDistance, bool caseSensitive, bool firstLetterMustMatch, params EditDistance.Match[] expected) { IList <EditDistance.Match> matches = EditDistance.GetClosestMatches(dictionary, term, maxEditDistance, caseSensitive, firstLetterMustMatch); for (int i = 0; i < expected.Length; i++) { Assert.IsTrue(i < matches.Count, "Expected match " + expected[i] + " was not returned."); Assert.AreEqual(expected[i].Term, matches[i].Term, "Match " + i + " is different."); Assert.AreEqual(expected[i].Distance, matches[i].Distance, "Match " + i + " has a different distance."); } if (expected.Length != matches.Count) { Assert.Fail(string.Format( "Expected {0} matches, but {1} were returned. The first unexpected match is {2}.", expected.Length, matches.Count, matches[expected.Length])); } }