public void DictionaryKeyLettersAreInAlphabeticalOrder()
        {
            FileWordReader reader = new FileWordReader(Path);

            Assert.IsTrue(reader.ReadWords().ContainsKey("alsu"));
            Assert.IsTrue(reader.ReadWords().ContainsKey("adgnsu"));
        }
        public void Setup()
        {
            using (StreamWriter writer = new StreamWriter("testreader.txt"))
            {
                writer.Write("Hello\nFred\nIt's\nWeds\n");
            }

            reader = new FileWordReader <WordNode_Stub_Pass>("testreader.txt");
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Blue Prism Technical Assessment Application");

            WordNode first = new WordNode {
                Word = args[0]
            };
            WordNode last = new WordNode {
                Word = args[1]
            };

            List <IWordNode> pool = new List <IWordNode>();

            ShortestSequenceCalculator <WordSequence, List <IWordNode> > calculator = new ShortestSequenceCalculator <WordSequence, List <IWordNode> > {
                Start = first, Finish = last, WordPool = pool
            };

            calculator.WordLength      = 4;
            calculator.FixedWordLength = true;
            try
            {
                Console.WriteLine("\nStart Word is \"" + args[0] + "\"");
                Console.WriteLine("Finish Word is \"" + args[1] + "\"");
                Console.WriteLine("Input File Path is \"" + args[2] + "\"");
                Console.WriteLine("Output File Path is \"" + args[3] + "\"");

                Console.WriteLine("\nLoading Word Pool from input file...");
                IWordReader reader = new FileWordReader <WordNode>(args[2]);
                reader.Open();
                calculator.Load(reader);
                reader.Close();
                Console.WriteLine(calculator.WordPoolSize + " Words Loaded");

                Console.WriteLine("Calculating Shortest Path...");
                WordSequence shortest  = new WordSequence();
                bool         pathFound = calculator.GetPath(shortest);
                if (pathFound)
                {
                    Console.WriteLine("Saving Results to Output File...");
                    var writer = new FileWordWriter(args[3]);
                    writer.Open();
                    shortest.Save(writer);
                    writer.Close();

                    Console.WriteLine("\nThe Shortest Path From \"" + args[0] + "\" to \"" + args[1] + "\" is:");
                    Console.WriteLine("[" + shortest.ToString() + "]");
                }
                else
                {
                    Console.WriteLine("There was no path between \"" + args[0] + "\" and \"" + args[1] + "\"");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public void AddsCorrectWordsToDictionaryValues()
        {
            FileWordReader reader    = new FileWordReader(Path);
            var            dictWords = reader.ReadWords();
            List <string>  words;
            bool           wordExists = dictWords.TryGetValue("adgnsu", out words);

            Assert.IsTrue(wordExists);
            Assert.IsTrue(words.Contains("dangus"));
            Assert.IsTrue(words.Contains("dugnas"));
            Assert.IsTrue(words.Contains("gandus"));
        }