public void TestConstructor01_SpecifyFilenameOnly() { string manifestFileName = Path.GetFileName(m_manifestPath1); using (WsActivationContext wsac = new WsActivationContext(manifestFileName)) { Assert.IsTrue(wsac.Loaded, "Should have successfully loaded the manifest from here."); using (WsActivationContext wsac2 = new WsActivationContext(manifestFileName)) { Assert.IsFalse(wsac2.Loaded, "Since the instance wsac is not disposed, we have already loaded a manifest from this path, so it was not loaded in the instance wsac2."); } } using (WsActivationContext wsac3 = new WsActivationContext(manifestFileName)) { Assert.IsTrue(wsac3.Loaded, "If no other instance has loaded the manifest, this should have loaded successfully"); } using (WsActivationContext wsac4 = new WsActivationContext("DummyManifestFile.Manifest")) { Assert.IsFalse(wsac4.Loaded, "This file does not exist so we should not have loaded anything."); } }
public void Execute() { m_resultsFolders = new ResultsFolders(); using (WsActivationContext wsac = new WsActivationContext()) { ProcessFolder(m_sFolder); } LogTheSummary(); SignalComplete(); }
public void TestInternalActionsPassActionTester() { using (WsActivationContext wsac = new WsActivationContext()) { foreach (string action in m_standardActions) { ActionTester actionTester = new ActionTester(action); actionTester.OnCompleteTestCase += new EventHandler<TestEventArgs>(OnCompleteTestCase); actionTester.RunTests(); } } }
public void TestRecipients() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { outlookEmailWrapper.ToRecipients = "Test <*****@*****.**>;blackhole <*****@*****.**>;[email protected]"; outlookEmailWrapper.CcRecipients = "[email protected];[email protected];[email protected]"; outlookEmailWrapper.BccRecipients = "[email protected];[email protected]"; outlookEmailWrapper.MailItem.Save(); RedemptionRecipientTableProxy outlookRecipientTableProxy = new RedemptionRecipientTableProxy(outlookEmailWrapper.MailItem, false/*Use Cache*/); NameValueCollection recipients = outlookRecipientTableProxy.GetProcessRecipients(OutlookRecipientTypes.ToRecipient); Assert.AreEqual(3, recipients.Count); int index = 0; // sometimes (x64 xp, o2007, vs2008) we don't get the single quotes round the names, which doesn't seem a problem Assert.AreEqual("Test", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); Assert.AreEqual("blackhole", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); Assert.AreEqual("*****@*****.**", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); recipients = recipients = outlookRecipientTableProxy.GetProcessRecipients(OutlookRecipientTypes.CcRecipient); Assert.AreEqual(3, recipients.Count); index = 0; Assert.AreEqual("*****@*****.**", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); Assert.AreEqual("*****@*****.**", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); Assert.AreEqual("*****@*****.**", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); recipients = recipients = outlookRecipientTableProxy.GetProcessRecipients(OutlookRecipientTypes.BccRecipient); Assert.AreEqual(2, recipients.Count); index = 0; Assert.AreEqual("*****@*****.**", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); Assert.AreEqual("*****@*****.**", recipients.Keys[index].Trim('\'')); Assert.AreEqual("*****@*****.**", recipients[index++]); outlookEmailWrapper.MailItem.Delete(); } }
public void TestConstructor02_SpecifyFullFilePath() { using (WsActivationContext wsac = new WsActivationContext(m_manifestPath1)) { Assert.IsTrue(wsac.Loaded, "Expected the manifest to be successfully loaded when specifying a fully qualified file path."); using (WsActivationContext wsac2 = new WsActivationContext(m_manifestPath1)) { Assert.IsFalse(wsac2.Loaded, "Since the instance wsac is not disposed, we have already loaded a manifest from this path, so it was not loaded in the instance wsac2."); } } using (WsActivationContext wsac = new WsActivationContext(@"C:\dummyManifestFile.manifest")) { Assert.IsFalse(wsac.Loaded, "No such file, so expected not to load anything"); } }
public void PreCache() { if (m_bPreCacheCalled) { // Ensure that we don't call this multiple times. return; } Logger.LogDebug("Start PreCache"); m_bPreCacheCalled = true; m_PreCacheEventWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); Thread startUp = new Thread(delegate() { try { PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.PreCache); using (WsActivationContext wsac = new WsActivationContext()) using (MailClientWorkerBase worker = Worker) { worker.PreCache(); } } //<excuse> // This code will execute during Outlook's startup. If there's some reason // we failed, we dont want to cause Outlook to crash. The reason for the failure will // be displayed later when a real mail item is sent, and then the user will be able to see the reason // for failure in a ProtectEnterprise context, instead of having Outlook blow up. //</excuse> catch (Exception ex) { Logger.LogError(ex); } finally { m_PreCacheEventWaitHandle.Set(); PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.PreCache, 0); } }); startUp.Name = "Workshare.Protect.PreCache"; startUp.IsBackground = true; startUp.Start(); }
public void TestSetHtmlFormattedBody() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatHTML; string bodyText = "We have a body that looks like something"; outlookEmailWrapper.Body = bodyText; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.IsTrue(proxy.BodyText.Contains(bodyText)); Assert.IsTrue(proxy.FormattedBodyText.Contains(bodyText)); string phrase = "Some HTML text"; bodyText = string.Format("<html>{0}</html>", phrase); proxy.BodyText = phrase; proxy.FormattedBodyText = bodyText; outlookEmailWrapper.MailItem.Save(); Assert.IsTrue(proxy.BodyText.Contains(phrase)); Assert.IsTrue(proxy.FormattedBodyText.Contains(phrase)); outlookEmailWrapper.MailItem.Delete(); } } }
public void TestEmbeddedAttachments() { throw new IgnoreException("TODO: TEST DISABLED FOR CHECKIN (RPC_E_SERVERFAULT in Outlook.Attachment.SaveAsFile()) - RNP 2010-04-16"); using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession, m_testPath + "HTML text e-mail This is a test mail with an embedded attachment.msg")) { byte[] originalDocBytes = System.IO.File.ReadAllBytes(m_testPath + "test.doc"); byte[] originalJpgBytes = System.IO.File.ReadAllBytes(m_testPath + "test.jpg"); // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.AreEqual(2, proxy.Attachments.Count); IEmailAttachment attachment1 = proxy.Attachments[0]; Assert.IsNotNull(attachment1); IEmailAttachment attachment2 = proxy.Attachments[1]; Assert.IsNotNull(attachment2); byte[] mimeDocBytes = System.IO.File.ReadAllBytes(attachment1.FileName); byte[] mimeJpgBytes = System.IO.File.ReadAllBytes(attachment2.FileName); TestHelpers.CompareByteArrays(originalDocBytes, mimeDocBytes, "The docs do not match"); TestHelpers.CompareByteArrays(originalJpgBytes, mimeJpgBytes, "The JPGs do not match"); Assert.IsTrue(string.IsNullOrEmpty(attachment1.ContentId)); Assert.IsFalse(string.IsNullOrEmpty(attachment2.ContentId)); Assert.AreEqual("[email protected]", attachment2.ContentId); outlookEmailWrapper.MailItem.Delete(); } } }
public void TestSetNullFormattedBody() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; string bodyText = "We have a body that looks like something"; outlookEmailWrapper.Body = bodyText; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.IsTrue(proxy.BodyText.Contains(bodyText)); Assert.IsTrue(proxy.FormattedBodyText.Contains(bodyText)); proxy.FormattedBodyText = null; outlookEmailWrapper.MailItem.Save(); Assert.IsTrue(string.IsNullOrEmpty(proxy.BodyText)); Assert.IsFalse(proxy.FormattedBodyText.Contains(bodyText)); outlookEmailWrapper.MailItem.Delete(); } } }
public void TestExtractCustomPropertiesFromSaveMsgFile() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession, m_testPath + "I have some MAPI properties.msg")) { // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { // We only interested in getting hold of the custom internet properties for this test System.Collections.Hashtable xHeaders = proxy.XHeaders; Assert.AreEqual(1, xHeaders.Count); Assert.IsTrue(xHeaders.ContainsKey("workshare_test3")); Assert.IsTrue(xHeaders.ContainsValue("test")); outlookEmailWrapper.MailItem.Delete(); } } }
public void TestExtractCustomPropertiesFromNewMessage() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { outlookEmailWrapper.Subject = "I have some properties"; outlookEmailWrapper.ToRecipients = "*****@*****.**"; outlookEmailWrapper.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatPlain; outlookEmailWrapper.Body = "We have a body that looks like something"; // Add some internet properties // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { // Only interested in Internet properties for this test outlookEmailWrapper.MailItem.Delete(); } } }
public void TestIsMatch() { //set up activation context here so that the real code doesn't try to read the manifest from the nunit shadow cache using (WsActivationContext wsac = new WsActivationContext()) { //test setup Workshare.Policy.Routing.InternalExternalRouter router = new Workshare.Policy.Routing.InternalExternalRouter(); UniversalRoutingEntity sourceEntity1 = new UniversalRoutingEntity(); sourceEntity1.PolicyType = PolicyType.ClientEmail; sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source; sourceEntity1.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook); RoutingItem smtpRoutingItem1 = new RoutingItem("*****@*****.**"); smtpRoutingItem1.Properties[SMTPItemPropertyKeys.Internal] = true.ToString(); sourceEntity1.Items.Add(smtpRoutingItem1); UniversalRoutingEntity smtpTargetEntity = new UniversalRoutingEntity(); smtpTargetEntity.PolicyType = PolicyType.ClientEmail; smtpTargetEntity.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source; smtpTargetEntity.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook); RoutingItem smtpTargetRoutingItem = new RoutingItem("Recipients:Internal"); smtpTargetEntity.Items.Add(smtpTargetRoutingItem); //test null data Assert.IsFalse(router.IsMatch(sourceEntity1, null), "Expected null data to return false"); Assert.IsFalse(router.IsMatch(null, smtpTargetEntity), "Expected null data to return false"); Assert.IsFalse(router.IsMatch(null, null), "Expected null data to return false"); //nominal case - includes internal only Assert.IsTrue(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected nominal internal address to return true"); // mixture of internal and external UniversalRoutingEntity sourceEntity2 = new UniversalRoutingEntity(); sourceEntity2.PolicyType = PolicyType.ClientEmail; sourceEntity2.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source; sourceEntity2.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook); RoutingItem smtpRoutingItem2 = new RoutingItem("*****@*****.**"); sourceEntity2.Items.Add(smtpRoutingItem2); RoutingItem smtpRoutingItem3 = new RoutingItem("*****@*****.**"); sourceEntity2.Items.Add(smtpRoutingItem3); Assert.IsFalse(router.IsMatch(sourceEntity2, smtpTargetEntity), "Expected mixture of internal and external address to return false"); //external only UniversalRoutingEntity sourceEntity3 = new UniversalRoutingEntity(); sourceEntity3.PolicyType = PolicyType.ClientEmail; sourceEntity3.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source; sourceEntity3.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook); RoutingItem smtpRoutingItem4 = new RoutingItem("*****@*****.**"); sourceEntity3.Items.Add(smtpRoutingItem4); Assert.IsFalse(router.IsMatch(sourceEntity3, smtpTargetEntity), "Expected external address to return false"); //mismatching request type sourceEntity1.PolicyType = PolicyType.ClientRemovableMedia; Assert.IsFalse(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected mismatching request type to return false"); sourceEntity1.PolicyType = PolicyType.ClientEmail; //mismatching routing type sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Destination; Assert.IsFalse(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected mismatching routing type to return false"); sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source; //no routing items in source sourceEntity2.Items.Clear(); Assert.IsFalse(router.IsMatch(sourceEntity2, smtpTargetEntity), "Expected no routing items in source to return false"); //no routing items in target smtpTargetEntity.Items.Clear(); Assert.IsFalse(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected no routing items in destination to return false"); //no request channel property sourceEntity1.Properties.Remove(SMTPPropertyKeys.RequestChannel); Assert.IsFalse(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected missing requestchannel property to return false"); } }
private void TestLoadAndCleanPPTFile(string fileName, FileType fileType, string ext) { using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile(fileName)) { // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(fileType); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ext, true)); props[CleanOption.Comments].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); testData.Properties.Add("CorrectedDisplayName", file.Filepath); action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForPowerPointToShutDown(30000); } } }
private void InternalExecute(object threadstate) { IDocumentPublisher8 publisher = null; ThreadState Result = threadstate as ThreadState; CustomiseRegionalSetting convert = new CustomiseRegionalSetting(); try { PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.PDF); using (WsActivationContext wsac = new WsActivationContext()) { publisher = new CDocumentPublisherClass(); m_outputFile = GetPdfFilename(m_streamProperties["FileName"]); Publish(publisher, m_inputFile, m_outputFile); if ((bool)m_actionPropertySet[PdfActionStringTable.ConvertToPDFA].Value) publisher.ConvertPDFToPDFA(m_outputFile); else publisher.SetPermission(m_outputFile, (string) m_actionPropertySet[PdfActionStringTable.Password].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitPrinting].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitEdit].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitCopy].Value, (bool) m_actionPropertySet[PdfActionStringTable.ProhibitComments].Value); m_streamProperties["FileName"] = m_outputFile; // Can't just assign the DisplayName property, PDFAction removes any path info from it, // we need to keep the path info because it describes the structure of zip files, ie if its in a folder in a zip its DisplayName would be "SomeFolder\\Document.docx" // If we loose "somefolder\\" we loose where in the zip the file came from. string newOutputPath = Path.Combine(Path.GetDirectoryName(m_streamProperties["DisplayName"]), Path.GetFileName(m_outputFile)); m_streamProperties["DisplayName"] = newOutputPath; TryDeleteFiles(m_inputFile); if (Result != null) Result.ThreadStateResult = true; } } catch (COMException ex) { Logger.LogError(ex); if (Result != null) Result.ExceptionCaught = ex; } catch (Exception ex) { Logger.LogError(ex); if (Result != null) Result.ExceptionCaught = ex; } finally { convert.RestoreCulture(); if (null != publisher) { Marshal.ReleaseComObject(publisher); } } }
public void TestConvertToMimeStreamRtfBodyWithAttachmentAddedByRef() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "RTF text e-mail: This is a test mail"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "*****@*****.**"; outlookEmailWrapper.BccRecipients = "*****@*****.**"; outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText; string rtfBody = "We have a body that looks like something"; outlookEmailWrapper.Body = rtfBody; outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "test.doc", Outlook.OlAttachmentType.olByReference); outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow; Request request = ConvertToRequestWithAttachment(m_testPath + "TestResultConvertToMimeStreamRtfBodyAddedByRef.txt", "test.doc", outlookEmailWrapper.MailItem); //properties Assert.AreEqual(8, request.Properties.Length); Assert.AreEqual(String.Empty, GetPropertyValue(MailMessagePropertyKeys.FileHeader, request.Properties), "Mismatch in Property"); Assert.IsTrue( GetPropertyValue(MailMessagePropertyKeys.Body,request.Properties ).Contains(rtfBody)); string resultantRtf = GetPropertyValue(MailMessagePropertyKeys.FormattedBody, request.Properties) ; Assert.IsTrue(resultantRtf.Contains("{\\rtf1"), "Mismatch in Property - body is not in RTF format"); Assert.IsTrue(resultantRtf.Contains(rtfBody), "Mismatch in Property - RTF body does not contain the correct body text"); Assert.AreEqual(subject, GetPropertyValue(MailMessagePropertyKeys.Subject,request.Properties ), "Mismatch in Property"); Assert.AreEqual("Outlook", GetPropertyValue(SMTPPropertyKeys.RequestChannel, request.Properties), "Mismatch in Property"); Assert.AreEqual("test.doc ", GetPropertyValue(MailMessagePropertyKeys.Attachments, request.Properties), "Mismatch in Property"); Assert.AreEqual( GetPropertyValue(MailMessagePropertyKeys.xPriority, request.Properties ), "5"); } }
public void TestGetEnumerator() { using (WsActivationContext wsac = new WsActivationContext()) { CreateNotesProxy(); Assert.IsNotNull(m_notesProxy); NotesProxy.Attachment proxyAttachment = new NotesProxy.AttachmentClass(); proxyAttachment.SetDisplayName("test.doc"); proxyAttachment.SetFileName(m_testPath + "test.doc"); proxyAttachment.SetContentItemIndex(1); proxyAttachment.SetContentId("B61002A0-1A85-48a5-9A95-7F254EECECF1"); m_notesProxy.AddAttachment(proxyAttachment); NotesMailProxy proxy = new NotesMailProxy(m_notesProxy); Assert.IsTrue(proxy.Attachments.IsReadOnly); System.Collections.IEnumerable enumerable = proxy.Attachments as System.Collections.IEnumerable; System.Collections.IEnumerator enumerator = enumerable.GetEnumerator(); while (enumerator.MoveNext()) { EmailAttachment attachment = enumerator.Current as EmailAttachment; Assert.AreEqual("test.doc", attachment.DisplayName); Assert.IsTrue(attachment.FileName.Contains("test.doc")); } } }
public void Test_01_BasicRoundTripForActionObjectOnly() { Process[] pro = Process.GetProcessesByName("winword"); if (pro != null && pro.Length != 0) throw new System.InvalidOperationException("winword should not be running"); using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile("Doc.doc")) { int revisionCount = 0; int commentCount = 0; GetRevisionAndCommmentCounts(file.Filepath, ref revisionCount, ref commentCount); Assert.AreEqual(1, revisionCount, "There is one track change in the document."); Assert.AreEqual(1, commentCount, "There is one comment in the document."); // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(FileType.WordDocument); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ".doc", true)); props[CleanOption.Comments].Value = true; props[CleanOption.TrackChanges].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); testData.Properties.Add("CorrectedDisplayName", file.Filepath); string outFile = action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForWordToShutDown(30000); GetRevisionAndCommmentCounts(outFile, ref revisionCount, ref commentCount); Assert.AreEqual(0, revisionCount, "Track changes should have been removed."); Assert.AreEqual(0, commentCount, "Comments should have been removed."); } } }
public void TestFallbackCleaningDoesntHappenInServerCtxt() { using (WsActivationContext wsac = new WsActivationContext()) { ActionPropertySet aps = new ActionPropertySet(new CleanActionPropertySet()); aps.SystemProperties["RunAt"] = new ActionProperty("RunAt", "Server"); // setup server execution context aps.SystemProperties.Add( "FileType", new ActionProperty("FileType", typeof(string), PropertyDisplayType.Default, false, false, ".ppt", true) ); // file is a password protected ppt document string tempFile = CopyFile(TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\TestDocuments\both.ppt")); ActionDataImpl adi = new ActionDataImpl(tempFile); adi.Properties["DisplayName"] = Path.GetFileName(tempFile); adi.Properties["FileName"] = tempFile; LightSpeedCleanUserAction lsua = new LightSpeedCleanUserAction(); try { // file is a password protected ppt document lsua.Execute(adi, aps); } catch (Exception ex) { // exceptions are ignored here as we are expecting the clean to blow up actually Console.WriteLine(ex.ToString()); } Assert.IsNotNull(lsua.FallbackTried); Assert.IsFalse(lsua.FallbackTried.Value, "Expecting no fallback"); } }
public void TestProxy() { using (WsActivationContext wsac = new WsActivationContext()) { CreateNotesProxy(); Assert.IsNotNull(m_notesProxy); string subject = "Plain text e-mail: This is a test mail"; m_notesProxy.SetSubject(subject); m_notesProxy.SetSender("DevBuild<*****@*****.**>"); m_notesProxy.SetResolvedRecipientsTypeToken("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F"); m_notesProxy.SetPriority(NotesProxy.NotesMailPriority.Normal); string body = "We have a body that looks like something"; m_notesProxy.SetBody(body); NotesProxy.Attachment proxyAttachment = new NotesProxy.AttachmentClass(); proxyAttachment.SetDisplayName("test.doc"); proxyAttachment.SetFileName(m_testPath + "test.doc"); proxyAttachment.SetContentItemIndex(1); proxyAttachment.SetContentId("B61002A0-1A85-48a5-9A95-7F254EECECF1"); m_notesProxy.AddAttachment(proxyAttachment); NotesMailProxy proxy = new NotesMailProxy(m_notesProxy); Assert.AreEqual(Workshare.Mime.Conversions.Priority.Normal, proxy.Priority); proxy.Priority = Workshare.Mime.Conversions.Priority.High; Assert.AreEqual(Workshare.Mime.Conversions.Priority.High, proxy.Priority); proxy.Priority = Workshare.Mime.Conversions.Priority.Normal; Assert.AreEqual("Plain text e-mail: This is a test mail", proxy.Subject); subject = "Let change the subject"; proxy.Subject = subject; Assert.AreEqual(subject, m_notesProxy.GetSubject()); Assert.AreEqual(body, proxy.FormattedBodyText); body = "The body has been changed"; proxy.FormattedBodyText = body; Assert.AreEqual(body, proxy.FormattedBodyText); Assert.AreEqual("DevBuild", proxy.Sender.Name); Assert.AreEqual("*****@*****.**", proxy.Sender.EmailAddress); EmailRecipient newSender = new EmailRecipient(); newSender.Name = "phantom"; newSender.EmailAddress = "*****@*****.**"; proxy.Sender = newSender; Assert.AreEqual("phantom", proxy.Sender.Name); Assert.AreEqual("*****@*****.**", proxy.Sender.EmailAddress); Assert.AreEqual(1, proxy.ToRecipients.Count); Assert.AreEqual(1, proxy.CcRecipients.Count); Assert.AreEqual(1, proxy.BccRecipients.Count); Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.ToRecipients[0].Name); Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.ToRecipients[0].EmailAddress); Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.CcRecipients[0].Name); Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.CcRecipients[0].EmailAddress); Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.BccRecipients[0].Name); Assert.AreEqual("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F", proxy.BccRecipients[0].EmailAddress); // Lets test the recipient iterator as well foreach (IEmailRecipient recipient in proxy.ToRecipients) { Assert.IsTrue(recipient.Name.Contains("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F")); } Assert.AreEqual(1, proxy.Attachments.Count); Assert.AreEqual("test.doc", proxy.Attachments[0].DisplayName); Assert.AreEqual("application/msword; name=test.doc", proxy.Attachments[0].ContentType); Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream"); // Lets test the attachment iterator as well foreach (IEmailAttachment attachment in proxy.Attachments) { Assert.IsTrue(attachment.DisplayName.Contains("test.doc")); } } }
public void TestLoadRTF() { using (WsActivationContext ac = new WsActivationContext()) { string sRedline = "\\redline.rtf"; WsCompose.WSRTFFile file = new WsCompose.WSRTFFile(); file.InputFileName = sRedline; file.ReadFile(); var pTarget = Helpers.MakeComStreamOnHGlobal(); file.GetRedlineML(pTarget as WsCompose.IStream); string sCreatedRedlineML = Helpers.ExtractTextFromIStream(pTarget); } }
public void TestSetRtfFormattedBody() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText; string bodyText = "We have a body that looks like something"; outlookEmailWrapper.Body = bodyText; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.IsTrue(proxy.BodyText.Contains(bodyText)); Assert.IsTrue(proxy.FormattedBodyText.Contains(bodyText)); string phrase = "Some RTF text"; StringBuilder rtfText = new StringBuilder(); rtfText.Append("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}"); rtfText.Append("{\\*\\generator Riched20 5.50.99.2014;}\\viewkind4\\uc1\\pard\\f0\\fs20\\par "); rtfText.Append(phrase); rtfText.Append("}"); proxy.BodyText = phrase; proxy.FormattedBodyText = rtfText.ToString(); outlookEmailWrapper.MailItem.Save(); Assert.IsTrue(proxy.BodyText.Contains(phrase)); Assert.IsTrue(proxy.FormattedBodyText.Contains(phrase)); outlookEmailWrapper.MailItem.Delete(); } } }
public void TestEmbeddedAttachments() { throw new IgnoreException("TODO: TEST DISABLED FOR CHECKIN (RPC_E_SERVERFAULT in Outlook.Attachment.SaveAsFile()) - RNP 2010-04-16"); using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession, m_testPath + "HTML text e-mail This is a test mail with an embedded attachment.msg")) { byte[] originalDocBytes = System.IO.File.ReadAllBytes(m_testPath + "test.doc"); byte[] originalJpgBytes = System.IO.File.ReadAllBytes(m_testPath + "test.jpg"); // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Email2Request email2Request = new Email2Request(proxy); Request request = email2Request.Convert(RequestChannel.Outlook, false); Assert.IsNotNull(request); outlookEmailWrapper.MailItem.Delete(); Assert.AreEqual("Outlook", GetPropertyValue(SMTPPropertyKeys.RequestChannel, request.Destination.Properties)); Assert.AreEqual("Outlook", GetPropertyValue(SMTPPropertyKeys.RequestChannel, request.Source.Properties)); Assert.AreEqual(2, request.Attachments.Length); Attachment attachment1 = request.Attachments[0]; Assert.IsNotNull(attachment1); Attachment attachment2 = request.Attachments[1]; Assert.IsNotNull(attachment2); TestHelpers.CompareByteArrays(originalDocBytes, attachment1.Content, "The docs do not match"); TestHelpers.CompareByteArrays(originalJpgBytes, attachment2.Content, "The JPGs do not match"); Assert.AreEqual("test.doc", attachment1.Name, "Mismatch in attachment name"); Assert.AreEqual("application/msword; name=test.doc", attachment1.ContentType, "Mismatch in attachment content type"); Assert.IsFalse(string.IsNullOrEmpty(attachment1.Id)); Assert.AreEqual("image001.jpg", attachment2.Name, "Mismatch in attachment name"); Assert.AreEqual("image/jpeg; name=image001.jpg", attachment2.ContentType, "Mismatch in attachment content type"); Assert.IsFalse(string.IsNullOrEmpty(attachment2.Id)); Assert.AreEqual("[email protected]", attachment2.Id); } } }
private void CreateProxy(Outlook.OlBodyFormat bodyFormat, out string proxyBodyText) { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "Test outlook proxy: This is a test mail"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "*****@*****.**"; outlookEmailWrapper.CcRecipients = "*****@*****.**"; outlookEmailWrapper.BccRecipients = "[email protected];[email protected]"; outlookEmailWrapper.BodyFormat = bodyFormat; outlookEmailWrapper.Body = "We have a body that looks like something"; outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "Mickey Mouse", Outlook.OlAttachmentType.olByValue); outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.AreEqual("Test outlook proxy: This is a test mail", proxy.Subject); Assert.IsTrue(proxy.FormattedBodyText.Contains("We have a body that looks like something")); proxyBodyText = proxy.FormattedBodyText; if (Environment.UserName == "lnpair") { Assert.AreEqual("lnpair", proxy.Sender.Name); Assert.AreEqual("*****@*****.**", proxy.Sender.EmailAddress); Assert.IsTrue(proxy.Sender.Internal); } Assert.IsTrue(proxy.ToRecipients.IsReadOnly); Assert.IsTrue(proxy.CcRecipients.IsReadOnly); Assert.IsTrue(proxy.BccRecipients.IsReadOnly); Assert.AreEqual(1, proxy.ToRecipients.Count); Assert.AreEqual(1, proxy.CcRecipients.Count); Assert.AreEqual(2, proxy.BccRecipients.Count); Assert.AreEqual("*****@*****.**", proxy.ToRecipients[0].Name.Trim('\'')); Assert.AreEqual("*****@*****.**", proxy.ToRecipients[0].EmailAddress); if (Environment.UserName == "lnpair") { Assert.IsFalse(proxy.ToRecipients[0].Internal); } Assert.AreEqual("*****@*****.**", proxy.CcRecipients[0].Name.Trim('\'')); Assert.AreEqual("*****@*****.**", proxy.CcRecipients[0].EmailAddress); if (Environment.UserName == "lnpair") { Assert.IsFalse(proxy.CcRecipients[0].Internal); } Assert.AreEqual("*****@*****.**", proxy.BccRecipients[0].Name.Trim('\'')); Assert.AreEqual("*****@*****.**", proxy.BccRecipients[0].EmailAddress); Assert.AreEqual("*****@*****.**", proxy.BccRecipients[1].Name.Trim('\'')); Assert.AreEqual("*****@*****.**", proxy.BccRecipients[1].EmailAddress); if (Environment.UserName == "lnpair") { Assert.IsFalse(proxy.BccRecipients[1].Internal); } Assert.AreEqual(Workshare.Mime.Conversions.Priority.High, proxy.Priority); // Lets test the recipient iterator as well foreach (IEmailRecipient recipient in proxy.ToRecipients) { Assert.IsTrue(recipient.Name.Contains("blackhole")); } Assert.AreEqual(1, proxy.Attachments.Count); // DE9310, requires to change this test behavior Assert.AreEqual("Mickey Mouse", proxy.Attachments[0].DisplayName); Assert.AreEqual("application/msword; name=Mickey Mouse", proxy.Attachments[0].ContentType); Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream"); // Lets test the attachment iterator as well foreach (IEmailAttachment attachment in proxy.Attachments) { // DE9310, requires to change this test behavior Assert.IsTrue(attachment.DisplayName.Contains("Mickey Mouse")); Assert.IsTrue(attachment.FileName.Contains("test.doc")); } outlookEmailWrapper.MailItem.Delete(); } } }
private static void ValidateRedlineMLRegeneratedFromRTF(string origFileName, string modFileName, string path, bool changeNumbersInRedline = true) { List<ISummaryItem> result = Helpers.ValidateSummaryList(origFileName, modFileName, path, (x) => x.SetOption((int) WsCompose.OptIds.OPTID_NUMBER_CHANGES, changeNumbersInRedline ? -1 : 0)); Dictionary<int, ChangeType> expectedChangeTypes = new Dictionary<int, ChangeType>(); foreach (ISummaryItem isi in result) { foreach (Change ch in isi.Changes) { expectedChangeTypes[ch.Number] = ch.Type; } } using (WsActivationContext ac = new WsActivationContext()) { string sRedline = Helpers.LastRTFRedline; WsCompose.WSRTFFile file = new WsCompose.WSRTFFile(); file.InputFileName = sRedline; file.ReadFile(); var pTarget = Helpers.MakeComStreamOnHGlobal(); file.GetRedlineML(pTarget as WsCompose.IStream); string sCreatedRedlineML = Helpers.ExtractTextFromIStream(pTarget); Assert.IsFalse(sCreatedRedlineML.Contains("Summary of deletions")); Assert.IsFalse(sCreatedRedlineML.Contains("Document comparison by")); Assert.IsFalse(sCreatedRedlineML.Contains("Redline Summary")); Assert.IsFalse(sCreatedRedlineML.Contains("Legend:")); Assert.IsFalse(sCreatedRedlineML.Contains("Statistics:")); Assert.IsFalse(sCreatedRedlineML.Contains(">80<"), "shouldn't be leaving change numbers in"); Helpers.ValidateRedlineML(sCreatedRedlineML); RedlineMLReader reader = new RedlineMLReader(new StringReader(sCreatedRedlineML)); RedlineDocument rd = reader.Execute(); SummaryItemBuilder bld = new SummaryItemBuilder(rd); List<ISummaryItem> result2 = bld.Execute(); Helpers.ValidateChangeNumbers(result2); foreach (ISummaryItem isi in result2) { foreach (Change ch in isi.Changes) { Assert.AreEqual(expectedChangeTypes[ch.Number], ch.Type, "Mismatched change type on " + ch.Number.ToString()); } } Assert.AreEqual(result.Count, result2.Count); } }
public void TestConvertToMimeStreamWithAttachmentAddedWhereDisplayNameDoesntHaveExtension() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "Plain text e-mail: This is a test mail"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "*****@*****.**"; outlookEmailWrapper.BccRecipients = "*****@*****.**"; outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; outlookEmailWrapper.Body = "We have a body that looks like something"; outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "test with no extension", Outlook.OlAttachmentType.olByValue); outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow; Request request = ConvertToRequestWithAttachment(m_testPath + "TestResultConvertToMimeStreamAddedByValue.txt", "test with no extension", outlookEmailWrapper.MailItem); //properties Assert.AreEqual(8, request.Properties.Length); Assert.AreEqual(String.Empty, GetPropertyValue(MailMessagePropertyKeys.FileHeader, request.Properties), "Mismatch in Property"); Assert.IsTrue(GetPropertyValue(MailMessagePropertyKeys.Body, request.Properties).Contains("We have a body that looks like something"), "Mismatch in Property"); Assert.IsTrue(GetPropertyValue(MailMessagePropertyKeys.FormattedBody, request.Properties).Contains("We have a body that looks like something"), "Mismatch in Property"); Assert.AreEqual(subject, GetPropertyValue(MailMessagePropertyKeys.Subject, request.Properties), "Mismatch in Property"); Assert.AreEqual("Outlook", GetPropertyValue(SMTPPropertyKeys.RequestChannel, request.Properties), "Mismatch in Property"); Assert.AreEqual("test with no extension ", GetPropertyValue(MailMessagePropertyKeys.Attachments, request.Properties), "Mismatch in Property"); Assert.AreEqual("5", GetPropertyValue(MailMessagePropertyKeys.xPriority, request.Properties)); } }
// TODO: ProtectProcess - fix test, bring back mime //[Test] public void TestConvertToMimeStreamWithAttachment() { using (WsActivationContext wsac = new WsActivationContext()) { CreateNotesProxy(); Assert.IsNotNull(m_notesProxy); string subject = "Plain text e-mail: This is a test mail"; m_notesProxy.SetSubject(subject); m_notesProxy.SetSender("DevBuild<*****@*****.**>"); m_notesProxy.SetResolvedRecipientsTypeToken("INTERNAL_TOKEN_F19CA8B3B44d13BCE9A38EC838E2C3224F74F2554c9586EA5DEBBCAD7F"); m_notesProxy.SetBody("We have a body that looks like something"); NotesProxy.Attachment proxyAttachment = new NotesProxy.AttachmentClass(); proxyAttachment.SetDisplayName("test.doc"); proxyAttachment.SetFileName(m_testPath + "test.doc"); proxyAttachment.SetContentItemIndex(1); proxyAttachment.SetContentId("B61002A0-1A85-48a5-9A95-7F254EECECF1"); m_notesProxy.AddAttachment(proxyAttachment); IUniversalRequestObject uro = ConvertToMimeStreamWithAttachment(m_testPath + "TestResultNotesConvertToMimeStreamAddedByValue.txt"); //properties Assert.AreEqual(8, uro.Properties.Count); Assert.AreEqual(String.Empty, uro.Properties[MailMessagePropertyKeys.FileHeader], "Mismatch in Property"); Assert.AreEqual("We have a body that looks like something", uro.Properties[MailMessagePropertyKeys.Body], "Mismatch in Property"); Assert.AreEqual("We have a body that looks like something", uro.Properties[MailMessagePropertyKeys.FormattedBody], "Mismatch in Property"); Assert.AreEqual(subject, uro.Properties[MailMessagePropertyKeys.Subject], "Mismatch in Property"); Assert.AreEqual("LotusNotes", uro.Properties[SMTPPropertyKeys.RequestChannel], "Mismatch in Property"); Assert.AreEqual("test.doc ", uro.Properties[MailMessagePropertyKeys.Attachments], "Mismatch in Property"); Assert.AreEqual("3", uro.Properties[MailMessagePropertyKeys.xPriority], "Mismatch in Property"); uro.OriginalContentBytes.Data.Dispose(); foreach (RequestAttachment ra in uro.Attachments) { ra.Dispose(); } } }
public void TestRoundTripDropAttachments() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "Test outlook proxy: TestRoundTripDropAttachments"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "*****@*****.**"; outlookEmailWrapper.CcRecipients = "*****@*****.**"; outlookEmailWrapper.BccRecipients = "[email protected];[email protected]"; outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText; string rtfBody = "We have a body that looks like something"; outlookEmailWrapper.Body = rtfBody; outlookEmailWrapper.AddAttachment(m_testPath + "test.doc", "Mickey Mouse", Outlook.OlAttachmentType.olByValue); outlookEmailWrapper.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { Assert.AreEqual(1, proxy.Attachments.Count); // DE9310, requires to change this test behavior Assert.AreEqual("Mickey Mouse", proxy.Attachments[0].DisplayName); Assert.AreEqual("application/msword; name=Mickey Mouse", proxy.Attachments[0].ContentType); Assert.IsTrue(proxy.Attachments[0].FileName.Contains("test.doc"), "Expected to find a non-empty stream"); // Lets convert the outlook mail message to MIME using (Email2Mime mailItem2Mime = new Email2Mime(proxy)) using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream()) using (MimeProxy mimeProxy = new MimeProxy(mimeStream)) { // Drop the attachments in the MIME stream mimeProxy.Attachments.Clear(); Email2Request email2Request = new Email2Request(mimeProxy); Request request = email2Request.Convert(RequestChannel.Outlook, false); outlookEmailWrapper.MailItem.Delete(); Assert.AreEqual(0, request.Attachments.Length); // Synchronise the email with the changes made to the URO //Assert.AreEqual(0, proxy.Attachments.Count); } } } }
public void TestSetSubject() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { outlookEmailWrapper.Subject = "Any old thing"; string testString = "This is a test"; using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) { proxy.Subject = testString; } Assert.AreEqual(testString, outlookEmailWrapper.Subject); } }
public void TestRecipientAddressInX400Format() { using (WsActivationContext wsac = new WsActivationContext()) using (OutlookEmailWrapper outlookEmailWrapper = new OutlookEmailWrapper(m_outlookSession)) { string subject = "Test outlook proxy: TestRecipientAddressInX400Format"; outlookEmailWrapper.Subject = subject; outlookEmailWrapper.ToRecipients = "BlackHole<*****@*****.**>"; outlookEmailWrapper.BodyFormat = Outlook.OlBodyFormat.olFormatRichText; string rtfBody = "We have a body that looks like something"; outlookEmailWrapper.Body = rtfBody; // We have to save the message in order to access all its contents :( outlookEmailWrapper.MailItem.Save(); using (RedemptionMailProxy proxy = new RedemptionMailProxy(outlookEmailWrapper.MailItem)) using (Email2Mime mailItem2Mime = new Email2Mime(proxy)) using (Stream mimeStream = mailItem2Mime.ConvertToMimeStream()) using (MimeProxy mimeProxy = new MimeProxy(mimeStream)) { Email2Request email2Request = new Email2Request(mimeProxy); Request request = email2Request.Convert(RequestChannel.Outlook, false); outlookEmailWrapper.MailItem.Delete(); // Now fake an X400 email address Workshare.PolicyContent.RoutingItem routingItem = request.Destination.Items[0]; Workshare.PolicyContent.RoutingItem modifiedRoutingItem = new Workshare.PolicyContent.RoutingItem(); modifiedRoutingItem.Content = "/O=WSDEV/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=BlackHole"; System.Collections.Generic.List< CustomProperty> custProps = new System.Collections.Generic.List<CustomProperty>(); foreach (CustomProperty prop in routingItem.Properties) { custProps.Add(prop); } custProps.Add(new CustomProperty(EmailProperties.ReadOnlyKey, bool.TrueString)); modifiedRoutingItem.Properties = custProps.ToArray(); request.Destination.Items = new Workshare.PolicyContent.RoutingItem[] { modifiedRoutingItem }; // Now do a convert again with the modified uro email2Request.Convert(RequestChannel.Outlook, request, false); Assert.AreEqual(1, request.Destination.Items.Length); routingItem = request.Destination.Items[0]; Assert.AreEqual("/O=WSDEV/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=BlackHole", routingItem.Content); Assert.AreEqual("BlackHole", GetPropertyValue(SMTPItemPropertyKeys.DisplayName, routingItem.Properties)); Assert.AreEqual(AddressType.To, GetPropertyValue(SMTPItemPropertyKeys.AddressType, routingItem.Properties)); Assert.AreEqual(bool.TrueString, GetPropertyValue(EmailProperties.ReadOnlyKey, routingItem.Properties)); } } }
public void Test_02_TestForRegionalSettings() { System.Globalization.CultureInfo oldCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fi-FI"); System.Globalization.CultureInfo newCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; try { Assert.AreNotEqual(oldCultureInfo, newCultureInfo); Assert.AreEqual(newCultureInfo, System.Globalization.CultureInfo.GetCultureInfo("fi-FI")); Process[] pro = Process.GetProcessesByName("excel"); if (pro != null && pro.Length != 0) throw new System.InvalidOperationException("excel should not be running"); using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile()) { file.setTempDir("Temp.xls"); file.CreateFile(); // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(FileType.ExcelSheet); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ".xls", true)); props[CleanOption.Comments].Value = true; props[CleanOption.TrackChanges].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); string outputFile = action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForExcelToShutDown(30000); Assert.AreEqual(newCultureInfo, System.Globalization.CultureInfo.GetCultureInfo("fi-FI")); } } } catch { } finally { System.Threading.Thread.CurrentThread.CurrentCulture = oldCultureInfo; } }