public void ZeroLengthInputs()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch(string.Empty, string.Empty);
            List <int> expected = new List <int>();

            Assert.IsTrue(IsEqual(expected, result));
        }
        public void ZeroLengthSearchString()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch("whatsapp hellow", string.Empty);
            List <int> expected = new List <int>();

            Assert.IsTrue(IsEqual(expected, result));
        }
        public void NoResult()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch("what is going on?", "whatsx goin on?");
            List <int> expected = new List <int>();

            Assert.IsTrue(IsEqual(expected, result));
        }
Exemple #4
0
        public void ZeroLengthInputs()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch("", "");
            List <int> expected = new List <int>();

            Assert.IsTrue(FuzzyMatchingUnitTest.IsEqual(expected, result));
        }
Exemple #5
0
        /// <summary>
        /// Search method that matches the title of windows with the user search text
        /// </summary>
        /// <param name="openWindows"></param>
        /// <returns>Returns search results</returns>
        private List <SearchResult> FuzzySearchOpenWindows(List <Window> openWindows)
        {
            List <SearchResult> result        = new List <SearchResult>();
            List <SearchString> searchStrings = new List <SearchString>();

            List <string> shortcuts = SettingsManager.Instance.GetShortcut(SearchText);

            foreach (var shortcut in shortcuts)
            {
                searchStrings.Add(new SearchString(shortcut, SearchResult.SearchType.Shortcut));
            }

            searchStrings.Add(new SearchString(searchText, SearchResult.SearchType.Fuzzy));

            foreach (var searchString in searchStrings)
            {
                foreach (var window in openWindows)
                {
                    var titleMatch   = FuzzyMatching.FindBestFuzzyMatch(window.Title, searchString.SearchText);
                    var processMatch = FuzzyMatching.FindBestFuzzyMatch(window.ProcessName, searchString.SearchText);

                    if ((titleMatch.Count != 0 || processMatch.Count != 0) &&
                        window.Title.Length != 0)
                    {
                        var temp = new SearchResult(window, titleMatch, processMatch, searchString.SearchType);
                        result.Add(temp);
                    }
                }
            }

            System.Diagnostics.Debug.Print("Found " + result.Count + " windows that match the search text");

            return(result);
        }
        public void RealWorldProgramManager()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch("Program Manager", "pr");
            List <int> expected = new List <int>()
            {
                0, 1
            };

            Assert.IsTrue(IsEqual(expected, result));
        }
        public void BestMatch()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch("aaacaab", "ab");
            List <int> expected = new List <int>()
            {
                5, 6
            };

            Assert.IsTrue(IsEqual(expected, result));
        }
        public void SimpleMatching()
        {
            List <int> result   = FuzzyMatching.FindBestFuzzyMatch("watsapp hellow", "hello");
            List <int> expected = new List <int>()
            {
                8, 9, 10, 11, 12
            };

            Assert.IsTrue(IsEqual(expected, result));
        }