Exemple #1
0
        private const int MAX_GUESS = 10; // Maximum range for shift guesses

        // Description: Tests all public functionality of the EncryptWord class
        // Preconditions: None
        // Postconditions: None
        public void RunTests()
        {
            Console.WriteLine("Starting tests...");
            Console.WriteLine("TEST 1");
            EncryptWord test1 = new EncryptWord();

            Console.WriteLine("Encrypted word [error]: "
                              + test1.EncodeWord("Tes"));
            Console.WriteLine("Decrypted word [error]: " + test1.DecodeWord());
            test1.ResetEverything();
            Console.WriteLine("Encrypted word: " + test1.EncodeWord("Test 1"));
            Console.WriteLine(test1.GetGuessStatistics());
            GuessAllValues(test1);
            Console.WriteLine(test1.GetGuessStatistics());
            Console.WriteLine("Decrypted word [Test 1]: " + test1.DecodeWord());

            Console.WriteLine("\nTEST 2");
            EncryptWord test2 = new EncryptWord("Hello, World!");

            Console.WriteLine(test2.GetGuessStatistics());
            GuessAllValues(test2);
            Console.WriteLine(test2.GetGuessStatistics());
            Console.WriteLine("Decrypted word [Hello, World!]: "
                              + test2.DecodeWord());

            Console.WriteLine("\nTESTING COMPLETE");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }