Esempio n. 1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void Main()
        {
            // This application will run as a console app if it is compiled so. If it is compiled as a Windows app,
            // it will be a Windows service (hence non-interactive)
            if (Environment.UserInteractive)
            {
                var chatBot = new ChatBot("ConsoleUser");

                while (true)
                {
                    Console.Write("You: ");
                    var input = Console.ReadLine();
                    if (string.IsNullOrEmpty(input) || input.ToLower() == "exit" || input.ToLower() == "quit" || input.ToLower() == "close")
                    {
                        break;
                    }

                    var response = chatBot.Chat(input);
                    Console.WriteLine("Bot: " + response);
                }
            }
            else
            {
                var servicesToRun = new ServiceBase[] { new ChatService() };
                ServiceBase.Run(servicesToRun);
            }
        }
Esempio n. 2
0
 public void TestLoadFromBinary()
 {
     _chatBot = new ChatBot();
     _chatBot.LoadFromBinaryFile();
     var output = _chatBot.Chat("bye", "1");
     Assert.AreEqual("Cheerio.", output.RawOutput);
 }
Esempio n. 3
0
 public void TestTimeOutChatWorks()
 {
     var chatBot = new ChatBot();
     const string path = @"AIML\Srai.aiml";
     {
         _loader.LoadAIML(path);
     }
     ChatBot.TimeOut = 30;
     var output = chatBot.Chat("infiniteloop1", "1");
     Assert.AreEqual("ERROR: The request has timed out.", output.Output);
 }