コード例 #1
0
ファイル: Program.cs プロジェクト: chaojian-zhang/MULTITUDE
        static bool VocabularyAndPatternUnitTestHelper(TheSystem Airi, string testString, string expectedOutput)
        {
            // Set up console output stream
            var originalConsoleOut = Console.Out; // preserve the original stream

            using (var writer = new StringWriter())
            {
                Console.SetOut(writer);

                // Do a test output
                Airi.SpeakNative(testString, "Passenger");

                // Get output string from redirected console
                writer.Flush();
                string outputString = writer.GetStringBuilder().ToString();

                // Compared and issue warning/errors
                if (outputString != expectedOutput || outputString == "")
                {
                    Console.SetOut(originalConsoleOut); // restore Console.Out
                    Console.WriteLine("[Error] Failed test: " + testString);
                    return(false);
                }

                // Clear stream for next output
                writer.GetStringBuilder().Clear();
            }
            Console.SetOut(originalConsoleOut); // restore Console.Out
            // Console.WriteLine("[Success] Passed test: " + testString);
            return(true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: chaojian-zhang/MULTITUDE
        static void VocabularyAndPatternTest()
        {
            // Create a new Airi System
            TheSystem Airi = new TheSystem();

            // Don't learn from auxiliary materials, but focus on basic understanding of Airi
            Console.WriteLine("Enter Text to communicate...");

            while (true)
            {
                Console.Write("Me: ");
                List <string> replies = Airi.SpeakNative(Console.ReadLine(), "Passenger");
                if (replies == null)
                {
                    Console.Write("\n");
                    continue;
                }
                Console.Write("Airi: ");
                foreach (string reply in replies)
                {
                    Console.WriteLine(reply);
                }
            }
        }