public void EmailRole() { MailQueue queue = new MailQueue(); EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), null, string.Empty, "*****@*****.**") { Roles = this.roleList, GetUsersFn = this.getUserFn, SystemSettings = this.systemSettings }; this.recipientList.Roles.Add("role-2"); EventResult result = handler.Handle(null, this.action, this.application, new PageList(), this.getApplicationAccessFn); Assert.IsTrue(result.Processed); MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable; Assert.AreEqual(2, message.To.Count); Assert.AreEqual("*****@*****.**", message.To[0].Address); Assert.AreEqual("*****@*****.**", message.To[1].Address); Assert.AreEqual("*****@*****.**", message.Sender.Address); Assert.AreEqual(this.action.Content, message.Body); Assert.AreEqual(this.action.Subject, message.Subject); }
public void SingleFieldRecipientInRepeater() { MailQueue queue = new MailQueue(); EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), null, string.Empty, "*****@*****.**") { Roles = this.roleList, GetUsersFn = this.getUserFn, SystemSettings = this.systemSettings }; ApplicationData data = new ApplicationData(); Dictionary<string, object>[] repeater = new Dictionary<string, object>[1]; repeater[0] = new Dictionary<string, object>(); repeater[0]["Email"] = "*****@*****.**"; data.Add("Repeater1", repeater); this.application.ApplicationData = data; this.recipientList.FormFields.Add("Repeater1[0].Email"); EventResult result = handler.Handle(null, this.action, this.application, new PageList(), this.getApplicationAccessFn); Assert.IsTrue(result.Processed); MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable; Assert.AreEqual(1, message.To.Count); Assert.AreEqual("*****@*****.**", message.To[0].Address); Assert.AreEqual("*****@*****.**", message.Sender.Address); Assert.AreEqual(this.action.Content, message.Body); Assert.AreEqual(this.action.Subject, message.Subject); }
public void EmailUserWithPdf() { MailQueue queue = new MailQueue(); EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), new ApplicationPdfWriter(), string.Format("{0}/iapply.pdf", System.IO.Path.GetTempPath()), "*****@*****.**") { Roles = this.roleList, GetUsersFn = this.getUserFn, SystemSettings = this.systemSettings }; this.action.AttachPdf = true; this.application.ApplicationData.Add("Test", "Test"); this.recipientList.Users.Add("user-1"); ControlList controlList = new ControlList(); TextControl textControl = new TextControl { Name = "Test", Label = "Test" }; controlList.Add(textControl); PageList pages = new PageList { new UserPage { Controls = controlList } }; EventResult result = handler.Handle(null, this.action, this.application, pages, this.getApplicationAccessFn); Assert.IsTrue(result.Processed); MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable; Assert.AreEqual(1, message.To.Count); Assert.AreEqual("*****@*****.**", message.To[0].Address); Assert.AreEqual("*****@*****.**", message.Sender.Address); Assert.AreEqual(1, message.Attachments.Count); Assert.AreEqual(this.action.Subject, message.Subject); }