/// <summary> /// Creates and starts an instance of SimpleSmtpServer that will listen on a specific port. /// </summary> /// <param name="port">port number the server should listen to</param> /// <param name="background">Whether listener thread blocks process from shutdown</param> /// <returns>The <see cref="SimpleSmtpServer">SmtpServer</see> waiting for message</returns> public static SimpleSmtpServer Start(int port, bool background = false) { SimpleSmtpServer server = new SimpleSmtpServer(port); Thread smtpServerThread = new Thread(server.Run); smtpServerThread.IsBackground = background; smtpServerThread.Start(); // Block until the server socket is created try { server.StartedEvent.WaitOne(); } catch { // Ignore don't care. } // If an exception occured during server startup, send it back. if (server.MainThreadException != null) { throw server.MainThreadException; } return(server); }
public static void Setup(TestContext testContext) { SmtpServer = SimpleSmtpServer.Start(25); }
/// <summary> /// Creates and starts an instance of SimpleSmtpServer that will listen on a specific port. /// </summary> /// <param name="port">port number the server should listen to</param> /// <param name="background">Whether listener thread blocks process from shutdown</param> /// <returns>The <see cref="SimpleSmtpServer">SmtpServer</see> waiting for message</returns> public static SimpleSmtpServer Start(int port,bool background = false) { SimpleSmtpServer server = new SimpleSmtpServer(port); Thread smtpServerThread = new Thread(server.Run); smtpServerThread.IsBackground = background; smtpServerThread.Start(); // Block until the server socket is created try { server.StartedEvent.WaitOne(); } catch { // Ignore don't care. } // If an exception occured during server startup, send it back. if (server.MainThreadException != null) { throw server.MainThreadException; } return server; }
protected void SetUp() { server = SimpleSmtpServer.Start(TEST_ALT_PORT); server2 = null; }
public SimpleSmtpServerTests() { server = null; server2 = null; }
public void Setup() { // NB Use port configured in App.config var client = new SmtpClient(); smtpServer = SimpleSmtpServer.Start(client.Port); }