Exemple #1
0
        public void MissingFile()
        {
            var path = Path.Combine(AssemblyDirectory, "MissingFile.txt");
            var res  = loader.Load(path);

            res.ToArray();
        }
Exemple #2
0
        public IEnumerable <string> Analyze()
        {
            string error = string.Empty;
            Dictionary <string, int> result = new Dictionary <string, int>();

            try
            {
                result = wordCounter.CountWords(bookLoader.Load(bookPath));
            }
            catch (FileNotFoundException)
            {
                error = "could not find file: " + bookPath;
            }
            catch (DirectoryNotFoundException)
            {
                error = "could not find directory containing file: " + bookPath;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            if (error.Length > 0)
            {
                yield return(error);
            }
            else
            {
                foreach (var kvp in result.OrderBy(a => a.Value))
                {
                    yield return(string.Format("Word: {0}, Count: {1}, Prime? {2}", kvp.Key, kvp.Value, primeTester.IsPrime(kvp.Value) ? "Yes" : "No"));
                }
            }
        }