public static string ToSandoSearchable(this String fieldValue) { if (String.IsNullOrWhiteSpace(fieldValue)) { return(fieldValue); } IWordSplitter wordSplitterImplementation = ExtensionPointsRepository.Instance.GetWordSplitterImplementation(); string splitWords; if (wordSplitterImplementation != null) { splitWords = String.Join(" ", wordSplitterImplementation.ExtractWords(fieldValue)); } else { //For testing, should never happend during execution splitWords = String.Join(" ", (new WordSplitter()).ExtractWords(fieldValue)); } if (splitWords == fieldValue) { return(fieldValue); } string result = fieldValue + Delimiter + splitWords; return(result); }
public void FindAndRegisterValidExtensionPoints_RegistersUsableCustomWordSplitter() { CreateExtensionPointsConfiguration(addValidWordSplitterConfiguration: true); ExtensionPointsConfigurationAnalyzer.FindAndRegisterValidExtensionPoints(extensionPointsConfiguration, logger); IWordSplitter wordSplitter = ExtensionPointsRepository.Instance.GetWordSplitterImplementation(); Assert.IsNotNull(wordSplitter, "Word splitter should be registered!"); Assert.AreEqual(wordSplitter.GetType().FullName, "Sando.TestExtensionPoints.TestWordSplitter", "Invalid word splitter returned!"); string[] splittedWords = null; Assert.DoesNotThrow(() => splittedWords = wordSplitter.ExtractWords("FileName")); Assert.IsTrue(splittedWords != null && splittedWords.Length == 2, "Invalid results from ExtractWords method!"); Assert.AreEqual(splittedWords[0], "File", "First splitted word is invalid!"); Assert.AreEqual(splittedWords[1], "Name", "Second splitted word is invalid!"); }