public void TestNoOperation() { const string welcomeMessage = "+OK"; const string okUsername = "******"; const string okPassword = "******"; const string noOperationOk = "+OK"; const string serverResponses = welcomeMessage + "\r\n" + okUsername + "\r\n" + okPassword + "\r\n" + noOperationOk + "\r\n"; Stream inputStream = new MemoryStream(Encoding.ASCII.GetBytes(serverResponses)); MemoryStream outputStream = new MemoryStream(); Pop3Client client = new Pop3Client(); client.Connect(new CombinedStream(inputStream, outputStream)); client.Authenticate("test", "test"); client.NoOperation(); // Get the last command issued by the client string output = GetLastCommand(new StreamReader(new MemoryStream(outputStream.ToArray())).ReadToEnd()); // We expect it to be NOOP const string expectedOutput = "NOOP"; Assert.AreEqual(expectedOutput, output); }
/// <summary> /// Used to connect client to server. /// </summary> private bool Connect() { client = new Pop3Client(); try { client.Connect(Pop3, Port, UseSsl); try { client.Authenticate(Client_Mail.ToString(), Password.ToString(), AuthenticationMethod.Auto); client.NoOperation(); ThreadStart processTaskThread = delegate { dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); dispatcherTimer.Start(); }; Thread thread = new Thread(processTaskThread); thread.Start(); return true; } catch { // user authentication error MessageBox.Show("User authentication error.", "error"); } } catch { // POP3 connection error MessageBox.Show("POP3 connection error.", "error"); } return false; }