Exemplo n.º 1
0
    protected override void Given() {
      var assemblies = new string[] { "ScheduMail.API" };
      var namespaces = new string[] { "ScheduMail.API.Contracts", "System.Linq","System.Xml.Linq" };

      sut = new TemplateParser(assemblies, namespaces);

      var promotion = @"<promotions>
                          <promotion>
                            <product>Widget 1</product>
                            <discount>20%</discount>
                            <expires>this month</expires>
                          </promotion>
                        </promotions>";

      var userData = XElement.Parse(promotion);

      templateData = new User
      {
        Title = "Mrs.",
        FirstName = "Nancy",
        Surname = "Davilio",
        EmailAddress = "*****@*****.**",
        Data = userData
      };

      template = @"
            <viewdata  User = ""ScheduMail.API.Contracts.User""/>
            <var  promotion = ""(from p in User.Data.Elements('promotion')
                                select new {
                                  Product = (string)p.Element('product'),
                                  Discount = (string)p.Element('discount'),
                                  Expires = (string)p.Element('expires')
                                }).FirstOrDefault()""/>
            Dear ${User.FirstName},

            We are excited to tell you about our latest offerings.  Due to your long standing account with us we would 
            like to give you a sneak peak at our latest product before commercial release. The ${promotion.Product} is the
            best thing since slice bread and for a limited time only we would like to extend you a discount of ${promotion.Discount}.

            Act soon because the offer is only good until the end of ${promotion.Expires}.

            Happy Buying!

            Click <a href='http://somecompany.com/unsubscribe?user=${User.EmailAddress}'>here</a> to unsubscribe from out mailings.
          ";
    }
Exemplo n.º 2
0
    protected override void Given() 
    {
      var assemblies = new string[] { "ScheduMail.API" };
      var namespaces = new string[] { "ScheduMail.API.Contracts" };

      sut = new TemplateParser(assemblies,namespaces);

      templateData = new User
      {
        Title = "Mrs.",
        FirstName = "Nancy",
        Surname = "Davilio",
        EmailAddress = "*****@*****.**"
      };

      template = @"
      <viewdata  User = ""ScheduMail.API.Contracts.User""/>
      Name: ${User.Title} ${User.FirstName} ${User.Surname}";
    }