public void can_read_a_file()
 {
     var template = new EmailTemplate();
     template.BodyFilePath = Path.Combine(GetBasePath(), @"Resources/TextForTest.txt");
     var content = template.Body;
     Assert.AreEqual("This is a test file.", content);
 }
 public void can_add_parameters()
 {
     var template = new EmailTemplate();
     template.Parameters.Add("{name}", "Toshio");
     template.Parameters.Add("{age}", 27);
     Assert.AreEqual(2, template.Parameters.Count);
 }
 public void can_add_mail_addresses()
 {
     var template = new EmailTemplate();
     template.ToAddress.Add("*****@*****.**");
     template.ToAddress.Add("*****@*****.**");
     Assert.AreEqual(2, template.ToAddress.Count);
 }
Example #4
0
 public void SendMessage(EmailTemplate template)
 {
     this.template = template;
     var message = CreateMessage();
     var client = new SmtpClient();
     client.EnableSsl = template.EnableSsl;
     client.Send(message);
 }
 public void process_a_template_with_keys_in_the_body_over_an_object()
 {
     var template = new EmailTemplate();
     template.Subject = "Test Subject";
     //First read a template
     template.BodyFilePath = Path.Combine(GetBasePath(), @"Resources/TemplateForTest.txt");
     //checks whether it contains the keys
     Assert.IsTrue(template.Body.Contains("{name}"));
     Assert.IsTrue(template.Body.Contains("{age}"));
     //creates an object with properties that match the keys
     var obj = new { name = "Toshio", age = 27 };
     //process the template with an object
     template.ProcessTemplate(obj);
     //checks if the keys have been exchanged with the corresponding values
     Assert.IsTrue(template.Body.Contains("Toshio"));
     Assert.IsTrue(template.Body.Contains("27"));
 }
 public void process_a_template_with_keys_in_the_body_over_parameters()
 {
     var template = new EmailTemplate();
     template.Subject = "Test Subject";
     //First read a template
     template.BodyFilePath = Path.Combine(GetBasePath(), @"Resources/TemplateForTest.txt");
     //checks whether it contains the keys
     Assert.IsTrue(template.Body.Contains("{name}"));
     Assert.IsTrue(template.Body.Contains("{age}"));
     //add the parameters that match the keys
     template.Parameters.Add("{name}", "Toshio");
     template.Parameters.Add("{age}", 27);
     //process the template with parameters
     template.ProcessTemplate();
     //checks if the keys have been exchanged with the corresponding values
     Assert.IsTrue(template.Body.Contains("Toshio"));
     Assert.IsTrue(template.Body.Contains("27"));
 }
 public FluentEmailSender()
 {
     this.sender = new Sender();
     this.emailTemplate = new EmailTemplate();
 }
 public FluentEmailSenderFinal(Sender sender, EmailTemplate emailTemplate)
 {
     this.emailTemplate = emailTemplate;
     this.sender = sender;
 }
 public void process_a_template_with_keys_in_the_subject_over_parameters()
 {
     var template = new EmailTemplate();
     template.Subject = "Hello {name}!";
     template.Body = "Body test";
     //add the parameters that match the keys
     template.Parameters.Add("{name}", "Toshio");
     //process the template with parameters
     template.ProcessTemplate();
     //checks if the keys have been exchanged with the corresponding values
     Assert.IsTrue(template.Subject.Contains("Toshio"));
 }
Example #10
0
 public void process_a_template_with_keys_in_the_subject_over_an_object()
 {
     var template = new EmailTemplate();
     template.Subject = "Hello {name}!";
     template.Body = "Body test";
     //creates an object with properties that match the keys
     var obj = new { name = "Toshio" };
     //process the template with an object
     template.ProcessTemplate(obj);
     //checks if the keys have been exchanged with the corresponding values
     Assert.IsTrue(template.Subject.Contains("Toshio"));
 }