Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                MainFlow main = new MainFlow();
                main.Run();
            }
            catch (ConfigurationErrorsException ex)
            {
                ConsoleWriter.WriteLine(ex.Message, Color.Red);

                LogManager.GetLogger().Error(ex);
            }
            catch (DirectoryNotFoundException ex)
            {
                ConsoleWriter.WriteLine($"Configured AgentPluginPath path not found. {ex.Message}", Color.Red);

                LogManager.GetLogger().Error(ex);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger().Error(ex);

                ConsoleWriter.WriteLine($"Application Error. Please check log.");
            }
            finally
            {
                ConsoleWriter.WriteLine();

                ConsoleWriter.WriteLine("Press any key to exit ...");

                Console.ReadLine();
            }
        }
Пример #2
0
        private static void RunChatRoom(Chat chat, MainFlow newMain)
        {
            var task = newMain.Run();

            task.ContinueWith(
                (t) =>
            {
                Botlog.WriteError(chat.Id, $"Faulted {t.Exception}", true);
                Chats.TryRemove(chat.Id, out _);
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
Пример #3
0
        public async Task Run(IEnumerable <TypedValue> expecteds, string value)
        {
            ConsoleWrapperMock.Setup(x => x.ReadLine(It.IsAny <string>()))
            .Returns <string>(x => value);

            TaskWrapperMock.Setup(x => x.Delay(It.IsAny <int>()))
            .Returns <int>(x => Task.CompletedTask);

            await MainFlow.Run();

            var count = expecteds.Count();

            TaskWrapperMock.Verify(x => x.Delay(It.IsAny <int>()), Times.Exactly(count));
            ConsoleWrapperMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(count));

            foreach (var e in expecteds)
            {
                ConsoleWrapperMock.Verify(x => x.WriteLine(e.ToString()), Times.Once);
            }
        }