예제 #1
0
        public void ParallelFindWordsbySearchString_NoWordFound_Test()
        {
            //Find no word
            var result   = WordSearchHelper.ParallelFindWordsbySearchString(_wordList, "xxxHello");
            var expected = new List <string> {
            };

            Assert.AreEqual(expected.Count, result.Count());
            Assert.IsTrue(result.Count() == 0);
        }
예제 #2
0
        public void ParallelFindWordsbySearchString_OneWord_Test()
        {
            //Find one word
            var result   = WordSearchHelper.ParallelFindWordsbySearchString(_wordList, "AAAA");
            var expected = new List <string> {
                "AAAAAAA"
            };

            Assert.AreEqual(expected.Count, result.Count());
            Assert.AreEqual(expected.First(), result.First());
        }
예제 #3
0
        public void ParallelFindWordsbySearchString_MoreWords_Test()
        {
            //Find 2 words
            var result   = WordSearchHelper.ParallelFindWordsbySearchString(_wordList, "XCamp");
            var expected = new List <string> {
                "XCamp is a great company", "XCamp workplace is nice", "XCamp", "xcamp", "XCAMP",
            };

            Assert.AreEqual(expected.Count, result.Count());

            foreach (string word in result)
            {
                Assert.IsTrue(expected.Contains(word));
            }
        }
        private async Task ExecuteSearchCommand()
        {
            await Task.Factory.StartNew(() =>
            {
                Stopwatch stopwatch = null;
                stopwatch           = Stopwatch.StartNew();
                var foundedWords    = WordSearchHelper.ParallelFindWordsbySearchString(_wordListModel.Items, SearchWord.Trim());
                stopwatch.Stop();

                return(new SearchResultModel(CreateWords(foundedWords), stopwatch.Elapsed.TotalMilliseconds, SearchWord));
            }
                                        ).ContinueWith(task =>
            {
                Results = "------------------------------------------------------------------\n" +
                          "Suchwort: " + task.Result.SearchWord + "; Laufzeit: " + task.Result.SearchDuration + " Millisekunde(n)\n" +
                          task.Result.FoundedWords + Results;
            });
        }
예제 #5
0
        static void Main(string[] args)
        {
            var wordList = WordListCreator.CreateDefaultWordList();

            //    new List<string>
            //{
            //    "AAAAAAA",
            //    "ZZZZZZ",
            //    "Hello, welcome...",
            //    "XCamp is a great company",
            //    "XCamp workplace is nice",
            //    "BBBZZZGGG",
            //    "hello Böblingen",
            //    "xcamp contain...",
            //    "xxcamp",
            //    "camp object is usefull",
            //    "earth is a beautifull planet",
            //    "earth environment changes to fast",
            //    "earth is the only planet where humans live"
            //};

            Console.WriteLine("--------Wortliste--------------------");
            foreach (string word in wordList)
            {
                Console.WriteLine(word);
            }

            Console.WriteLine("\nSuchen sie ein Wort: ");

            string searchString = Console.ReadLine();

            Console.WriteLine();

            var foundedWords = WordSearchHelper.ParallelFindWordsbySearchString(wordList, searchString);

            Console.WriteLine("Ergebnisse für {0}: ", searchString);
            foreach (string word in foundedWords)
            {
                Console.WriteLine(word);
            }

            Console.ReadLine();
        }
예제 #6
0
        public void ParallelFindWordsbySearchString_InvalidInput_Test()
        {
            //search string is empty
            var result   = WordSearchHelper.ParallelFindWordsbySearchString(_wordList, string.Empty);
            var expected = new List <string>();

            Assert.AreEqual(expected.Count, result.Count());

            //search string is null
            result = WordSearchHelper.ParallelFindWordsbySearchString(_wordList, null);
            Assert.AreEqual(expected.Count, result.Count());

            //Word list is empty
            result = WordSearchHelper.ParallelFindWordsbySearchString(new List <string>(), null);
            Assert.AreEqual(expected.Count, result.Count());

            //word list is null
            result = WordSearchHelper.ParallelFindWordsbySearchString(null, null);
            Assert.AreEqual(expected.Count, result.Count());
        }