コード例 #1
0
        public void TestAttachmentEncoding()
        {
            var testFiles = GetTestFiles();

            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            foreach (string testFile in testFiles)
            {
                Trace.WriteLine(testFile);


                string fileHash = Utilities.GetFileHash(testFile);

                MailMessage mail = new MailMessage();
                mail.From = new System.Net.Mail.MailAddress("*****@*****.**");
                mail.To.Add("*****@*****.**");
                mail.Subject = "Test";
                mail.Attachments.Add(new Attachment(testFile));

                SmtpClient client = new SmtpClient("localhost", 25);
                client.Send(mail);

                POP3Simulator.AssertMessageCount("*****@*****.**", "test", 1);

                POP3Simulator sim = new POP3Simulator();
                sim.ConnectAndLogon("*****@*****.**", "test");
                string fileContent = sim.RETR(1);
                sim.DELE(1);
                sim.QUIT();


                hMailServer.Message message = new hMailServer.Message();

                try
                {
                    File.WriteAllText(message.Filename, fileContent);
                    message.RefreshContent();

                    message.Attachments[0].SaveAs(message.Filename);
                    string fileHashAfter = Utilities.GetFileHash(message.Filename);

                    Assert.AreEqual(fileHash, fileHashAfter);
                }
                finally
                {
                    File.Delete(message.Filename);
                }
            }
        }
コード例 #2
0
 public void RefreshContent()
 {
     _object.RefreshContent();
 }