public void CanStartTwitterServer()
 {
     using (ITwitterServer twitterServer = new TwitterTcpServer(new TcpEndPointDetails(), new TwitterTcpListener(new TcpEndPointDetails(), new TwitterHandler(), new ConsoleLogger())))
     {
         Assert.AreEqual(twitterServer.Status, ServerStatus.Stopped);
         twitterServer.Start();
         Assert.AreEqual(twitterServer.Status, ServerStatus.Started);
         Assert.IsNotNull(twitterServer.TwitterListener);
         Assert.AreEqual(twitterServer.TwitterListener.Status, ListenerStatus.Started);
     }
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     Console.WriteLine("Starting Server...");
     TcpEndPointDetails tcpEndpointDetails = new TcpEndPointDetails { IpAddress = "127.0.0.1", Port = 10101 };
     using (ITwitterServer twitterServer = new TwitterTcpServer(
         tcpEndpointDetails, new TwitterTcpListener(tcpEndpointDetails,
             new TwitterHandler(),
             new ConsoleLogger())))
     {
         twitterServer.Start();
         Console.WriteLine("Server started.");
         Console.WriteLine("Type 'exit' to stop server.");
         string line = null;
         while ((line = Console.ReadLine()) != null)
         {
             if (line.ToLowerInvariant().Equals("exit"))
             {
                 break;
             }
         }
         Console.WriteLine("Stopping Server...");
     }
     Console.WriteLine("Server stopped.");
 }