Exemplo n.º 1
0
        public WordSearchResultDto SearchForWords(string letters)
        {
            System.Diagnostics.Debug.WriteLine($"Searching for {letters}");
            Stopwatch watch = new System.Diagnostics.Stopwatch();

            watch.Start();
            WordSearchResultDto output = new WordSearchResultDto();

            if (letters == null || letters.Length < 4)
            {
                output.Words = Enumerable.Empty <IndividualWordResultDto>();
            }
            else
            {
                output.Words = SearchForWords(new WordCount(letters)).Select(s => new IndividualWordResultDto(s)).OrderByDescending(s => s.Length);
            }


            watch.Stop();
            output.TimeTaken = watch.ElapsedMilliseconds;

            return(output);
        }
Exemplo n.º 2
0
        public void TestForNullInput()
        {
            WordSearchResultDto result = Controller.SearchForWords(null);

            Assert.Empty(result.Words);
        }
Exemplo n.º 3
0
        public void TestForSingleResponse(string searchString)
        {
            WordSearchResultDto result = Controller.SearchForWords(searchString);

            Assert.Single(result.Words);
        }