示例#1
0
        public void DownloadAttachmentsToConfigLocation()
        {
            MimeMessage   singleMessage = this.EmailDriver.GetMessage("TestInbox", MimeMessageUID);
            List <string> attchments    = this.EmailDriver.DownloadAttachments(singleMessage);

            try
            {
                Assert.AreEqual(3, attchments.Count, "Expected 3 attachments");

                foreach (string file in attchments)
                {
                    string downloadFileHash = this.GetFileHash(file);
                    string testFileHash     = this.GetFileHash(Path.Combine(EmailConfig.GetAttachmentDownloadDirectory(), Path.GetFileName(file)));

                    Assert.AreEqual(testFileHash, downloadFileHash, Path.GetFileName(file) + " test file and download file do not match");
                }
            }
            finally
            {
                foreach (string file in attchments)
                {
                    File.Delete(Path.Combine(EmailConfig.GetAttachmentDownloadDirectory(), Path.GetFileName(file)));
                }
            }
        }
示例#2
0
 public void GetDownloadDirectoryTest()
 {
     #region DownloadDirectory
     string downloadDirectory = EmailConfig.GetAttachmentDownloadDirectory();
     #endregion
     Assert.AreEqual(@"C:\Frameworks\downloads", downloadDirectory);
 }
示例#3
0
        public void DownloadAttachmentsToTestDefinedLocation()
        {
            // Setup a test download location
            string downloadLocation = Path.Combine(EmailConfig.GetAttachmentDownloadDirectory(), Guid.NewGuid().ToString());
            string testFilePath     = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestFiles");

            try
            {
                MimeMessage   singleMessage = this.EmailDriver.GetMessage("TestInbox", MimeMessageUID);
                List <string> attchments    = this.EmailDriver.DownloadAttachments(singleMessage, downloadLocation);

                Assert.AreEqual(3, attchments.Count, "Expected 3 attachments");

                foreach (string file in attchments)
                {
                    string tempDownload = Path.Combine(downloadLocation, Guid.NewGuid().ToString());

                    // Fix weird Git related CRLF issue
                    if (file.EndsWith(".cs"))
                    {
                        string value = File.ReadAllText(Path.Combine(testFilePath, Path.GetFileName(file))).Replace("\r\n", "\n").Replace("\n", "\r\n");
                        File.WriteAllText(tempDownload, value);

                        value = File.ReadAllText(file).Replace("\r\n", "\n").Replace("\n", "\r\n");
                        File.WriteAllText(file, value);
                    }
                    else
                    {
                        File.Copy(Path.Combine(testFilePath, Path.GetFileName(file)), tempDownload);
                    }

                    string downloadFileHash = this.GetFileHash(file);
                    string testFileHash     = this.GetFileHash(tempDownload);

                    Assert.AreEqual(testFileHash, downloadFileHash, Path.GetFileName(file) + " test file and download file do not match");
                }
            }
            finally
            {
                Directory.Delete(downloadLocation, true);
            }
        }
        public void GetDownloadDirectoryTest()
        {
            string downloadDirectory = EmailConfig.GetAttachmentDownloadDirectory();

            Assert.AreEqual(@"/tmp/emailmaqsdownloads", downloadDirectory);
        }