Пример #1
0
 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"));
 }
Пример #2
0
 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"));
 }
Пример #3
0
 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"));
 }
Пример #4
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"));
 }