Example #1
0
        private void OnTcpClientAccepted(Task <TcpClient> task_)
        {
            var tcpClient      = task_.Result;
            var networkStream  = tcpClient.GetStream();
            var smtpStream     = new SmtpServerStream(networkStream);
            var smtpConnection = new DummySmtpServerConnection(smtpStream, _mailBag, _connections);

            _connections.Add(smtpConnection);
            smtpConnection.Start();

            lock (_lock)
            {
                _listener.AcceptTcpClientAsync().ContinueWith(OnTcpClientAccepted);
            }
        }
Example #2
0
        /// <summary>
        /// Creates a new instance of a <code>TestSmtpServerConnection</code>. Requires an <code>SmtpServerStream</code>,
        /// a <code>IMailCollector</code> (usually a <code>IMailBag</code> to consume the receive emails and a
        /// <code>ITestSmtpServerConnectionCollection</code> (from the parent server).
        /// </summary>
        /// <param name="stream_"></param>
        /// <param name="mailCollector_"></param>
        /// <param name="connections_"></param>
        public DummySmtpServerConnection(SmtpServerStream stream_, IMailCollector mailCollector_, IDummySmtpServerConnectionCollection connections_)
        {
            if (null == stream_)
            {
                throw new ArgumentNullException("stream_");
            }

            if (null == mailCollector_)
            {
                throw new ArgumentNullException("mailCollector_");
            }

            if (null == connections_)
            {
                throw new ArgumentNullException("connections_");
            }

            _lock          = new object();
            _mailCollector = mailCollector_;
            _connections   = connections_;
            _stream        = stream_;
            _recipientList = new List <string>();
        }