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")); } } }
// 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 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")); } } }