public IEnumerable <string> GetSuggestionsFor(string input) { var suggestions = new List <string>(); if (string.IsNullOrWhiteSpace(input)) { return(suggestions); } var directory = GetDirectory(input); if (string.IsNullOrEmpty(directory)) { return(suggestions); } var startOfNextEntry = GetStartOfNextEntry(input); switch (_completionType) { case CompletionType.FilesOnly: return(_fileSystemManager.FilenamesIn(directory, startOfNextEntry)); case CompletionType.FoldersOnly: return(_fileSystemManager.FoldernamesIn(directory, startOfNextEntry)); default: return(_fileSystemManager.FileAndFolderNamesIn(directory, startOfNextEntry)); } }
public void ShouldGetFoldersOnlyIfSpecified() { using (_mockRepository.Record()) { Expect.Call(_fileSystemManagerMock.DirectoryExists(SomeFolder)).Return(true); Expect.Call(_fileSystemManagerMock.FoldernamesIn(SomeFolder, string.Empty)).Repeat.Once() .Return(SomeFolders); } using (_mockRepository.Playback()) { _provider = new FileSystemAutoCompleteProvider(_fileSystemManagerMock, CompletionType.FoldersOnly); var suggestions = _provider.GetSuggestionsFor(SomeFolder); CollectionAssert.AreEqual(SomeFolders, suggestions); } }