public EmailMessageHelper(string pstFile, string rootFolderName) { m_sender = new EmailSender(); m_app = m_sender.Initialise(); //Create a copy of the PST file and only work with the copy. m_pstCopy = String.Format("{0}{1}COPY.PST", Path.GetTempPath(), Path.GetFileNameWithoutExtension(pstFile)); File.Copy(pstFile, m_pstCopy, true); Assert.IsTrue( File.Exists( m_pstCopy )); m_mounter = new MailFolderMounter(m_app, m_pstCopy); MSOutlook.Folders folders = m_mounter.ETFolder.Folders; using (new ComObjectGovernor(folders)) { m_rootFolder = folders[rootFolderName]; Assert.IsNotNull(m_rootFolder, "Cannot find the folder containing the test emails"); } }
public void TestEATFolderEmailsWeExpectToBlock() { using(MailFolderMounter tfm = new MailFolderMounter(m_outlookApplication, Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\AcceptanceTests.PolicyObjectModel.Tests\TestFiles\TrafficTests.pst"))) { int iExamples = m_eSender.GetEATTestMailCount("MailsToBlock"); Assert.IsTrue(iExamples > 0, "You do not have any e-mails to test - check the Outlook folder"); Assert.IsTrue(iExamples < 30, "More than 30 send examples makes this test slow. Are you sure?"); for (int iIndex = 0; iIndex < iExamples; ++iIndex) { _MailItem mailItemOriginal = m_eSender.GetEATTestMailAtIndex("MailsToBlock", iIndex); _MailItem mailItemForward = ForwardEmailItemExternally(mailItemOriginal); m_eSender.VerifyProtectDialogIsShownAndCancelIt(mailItemForward); // Just testing policy action here at this time. See doc test for application of policy rather than clutter the e-mail system } } }
public void TestEATFolderEmailsWeExpectToIgnore() { using (MailFolderMounter tfm = new MailFolderMounter(m_outlookApplication, Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\AcceptanceTests.PolicyObjectModel.Tests\TestFiles\TrafficTests.pst"))) { int iExamples = m_eSender.GetEATTestMailCount("MailsToTransmit"); Assert.IsTrue(iExamples > 0, "You do not have any e-mails to test - check the Outlook folder"); Assert.IsTrue(iExamples < 10, "More than 10 send examples makes this test slow. Are you sure?"); for (int iIndex = 0; iIndex < iExamples; ++iIndex) { _MailItem mailItemOriginal = m_eSender.GetEATTestMailAtIndex("MailsToTransmit", iIndex); _MailItem mailItemForward = ForwardEmailItemExternally(mailItemOriginal); m_eSender.VerifyMailIsSentWithoutProtectDialog(mailItemForward); } } }
public void TestEATFolderEmailsWeExpectToPDF() { using (MailFolderMounter tfm = new MailFolderMounter(m_outlookApplication, testDataDir + @"TrafficTests2.pst")) { int iExamples = m_eSender.GetEATTestMailCount("MailsToPDF"); Assert.IsTrue(iExamples > 0, "You do not have any e-mails to test - check the Outlook folder"); Assert.IsTrue(iExamples < 30, "More than 30 send examples makes this test slow. Are you sure?"); for (int iIndex = 0; iIndex < iExamples; ++iIndex) { _MailItem mailItemOriginal = m_eSender.GetEATTestMailAtIndex("MailsToPDF", iIndex); string sSubjectOriginal = mailItemOriginal.Subject; _MailItem mailItemForward = ForwardEmailItemExternally(mailItemOriginal); string sSubjectF = mailItemForward.Subject; bool bPassed = false; string sDocNames = string.Empty; Microsoft.Office.Interop.Outlook.Attachments attachments = mailItemForward.Attachments; int nAttachmentCount = attachments.Count; if (nAttachmentCount >= 1) { for (int i = 1; i <= nAttachmentCount; i++) { if (sDocNames.Length > 0) sDocNames += ';'; sDocNames += mailItemForward.Attachments[i].DisplayName; } m_eSender.VerifyProtectDialogIsShownToggleAllChecks(mailItemForward); _MailItem sentMailItem = m_eSender.FindEmailInSentItemsBySubject(sSubjectF); if (sentMailItem != null) { bPassed = AllAttachmentsWereConvertedToPDF(nAttachmentCount, sentMailItem); } EATReportEmail("PDF", sDocNames, sSubjectOriginal, bPassed); } } } }