Exemplo n.º 1
0
 /// <summary>
 ///  Main app run point
 ///  Due to depency with static Console this proved to be untestable
 ///  To be fixed
 /// </summary>
 public void Run(RunSettings runSettings)
 {
     Console.WriteLine($"Starting in {runSettings.Mode} mode...");
     echoApp = echoAppFactory.GetEchoApp(runSettings.Mode);
     Console.WriteLine("Attempting to connect...");
     echoApp.MessageHandler = Console.WriteLine;
     echoApp.Start(runSettings);
     while (true)
     {
         Console.WriteLine("Enter a message to send and press enter or enter exit to stop the the program");
         var input = Console.ReadLine();
         if (input == "exit")
         {
             echoApp.Stop();
             Console.WriteLine("Press any key to exit");
             break;
         }
         var messageSentSuccessfully = echoApp.SendMessage(input);
         if (!messageSentSuccessfully)
         {
             Console.WriteLine($"Could not send message {input}");
         }
     }
 }
 public EchoAppFactory([Named("clientApp")] IEchoApp clientApp, [Named("serverApp")] IEchoApp serverApp)
 {
     this.clientApp = clientApp;
     this.serverApp = serverApp;
 }