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(); } }
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); }
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); } }