本文整理汇总了C#中Parser.InitializeEmail方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.InitializeEmail方法的具体用法?C# Parser.InitializeEmail怎么用?C# Parser.InitializeEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.InitializeEmail方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldReturnAStringVariable
public void ShouldReturnAStringVariable()
{
const string input = "Hey, {{firstName}}! What's up?";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.BooleanLogics.Count == 0);
Assert.IsTrue(result.StringVariables.Count == 1);
Assert.IsTrue(result.StringVariables.Any(a => a.Name == "firstName"));
}
示例2: BooleanVariablesShouldSupportDescriptions
public void BooleanVariablesShouldSupportDescriptions()
{
const string input = "I {{#have|Random Description}}was awesome{{/have}}!";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.StringVariables.Count == 0);
Assert.IsTrue(result.BooleanLogics.Count == 1);
Assert.IsTrue(result.BooleanLogics[0].Description == "Random Description");
Assert.IsTrue(result.BooleanLogics[0].Name == "have");
}
示例3: ShouldReturnASingleBooleanLogic
public void ShouldReturnASingleBooleanLogic()
{
const string input = "In the beginning, there was {{#ifGreaterThanOne}}one and{{/ifGreaterThanOne}} only one subject";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.BooleanLogics.Count == 1);
Assert.IsTrue(result.StringVariables.Count == 0);
Assert.IsTrue(result.BooleanLogics.Any(a => a.Name == "ifGreaterThanOne"));
}
示例4: ShouldReturnTwoBooleanLogics
public void ShouldReturnTwoBooleanLogics()
{
const string input =
"In the {{#ifGreater}}beginning{{/ifGreater}}{{#ifLesser}}end{{/ifLesser}}, there was something.";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.BooleanLogics.Count == 2);
Assert.IsTrue(result.StringVariables.Count == 0);
Assert.IsTrue(result.BooleanLogics.Any(a => a.Name == "ifGreater"));
Assert.IsTrue(result.BooleanLogics.Any(a => a.Name == "ifLesser"));
}
示例5: StringVariableShouldSupportDescriptions
public void StringVariableShouldSupportDescriptions()
{
const string input = "I have {{number|Number of pickles}} pickles!";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.BooleanLogics.Count == 0);
Assert.IsTrue(result.StringVariables.Count == 1);
Assert.IsTrue(result.StringVariables[0].Name == "number");
Assert.IsTrue(result.StringVariables[0].Description == "Number of pickles");
}
示例6: ShouldReturnTwoVariables
public void ShouldReturnTwoVariables()
{
const string input = "So, get this, {{firstPerson}}. There was this guy named {{secondPerson}}, right?";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.BooleanLogics.Count == 0);
Assert.IsTrue(result.StringVariables.Count == 2);
Assert.IsTrue(result.StringVariables.Any(a => a.Name == "firstPerson"));
Assert.IsTrue(result.StringVariables.Any(a => a.Name == "secondPerson"));
}
示例7: CombineVariablesTestWithDescriptions
public void CombineVariablesTestWithDescriptions()
{
const string input =
"Don't {{verb}} each {{#repeater}}and every {{/repeater}}{{time|Days or weeks}} by the {{noun}} you reap{{#includeRest|Includes the rest of the phrase}}, but by the {{otherNoun}}s that you plant{{/includeRest}}.";
var template = new Template
{
Subject = "My {{verb}}",
TextTemplate = input
};
var service = new Parser();
var emailScope = service.InitializeEmail(template);
emailScope.StringVariables.First(a => a.Name == "verb").Value = "judge";
emailScope.BooleanLogics.First(a => a.Name == "repeater").Value = false;
emailScope.StringVariables.First(a => a.Name == "time").Value = "day";
emailScope.StringVariables.First(a => a.Name == "noun").Value = "harvest";
emailScope.BooleanLogics.First(a => a.Name == "includeRest").Value = true;
emailScope.StringVariables.First(a => a.Name == "otherNoun").Value = "seed";
var output = service.FinalizeTemplate(emailScope);
Assert.AreEqual("Don't judge each day by the harvest you reap, but by the seeds that you plant.", output.PlainEmailBody);
Assert.AreEqual("My judge", output.Subject);
Assert.IsTrue(emailScope.StringVariables.First(a => a.Name == "time").Description == "Days or weeks");
Assert.IsTrue(emailScope.StringVariables.First(a => a.Name == "verb").Description == "");
Assert.IsTrue(emailScope.BooleanLogics.First(a => a.Name == "includeRest").Description == "Includes the rest of the phrase");
Assert.IsTrue(emailScope.BooleanLogics.First(a => a.Name == "repeater").Description == "");
}
示例8: CombineDuplicateVariablesTest
public void CombineDuplicateVariablesTest()
{
const string input =
"Don't {{verb}} each {{#repeater}}and every {{/repeater}}{{time}} by the {{noun}} you reap{{#includeRest}}, but by the {{otherNoun}}s that you plant{{/includeRest}}. Yes, {{otherNoun}}s.";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var emailScope = service.InitializeEmail(template);
emailScope.StringVariables.First(a => a.Name == "verb").Value = "judge";
emailScope.BooleanLogics.First(a => a.Name == "repeater").Value = false;
emailScope.StringVariables.First(a => a.Name == "time").Value = "day";
emailScope.StringVariables.First(a => a.Name == "noun").Value = "harvest";
emailScope.BooleanLogics.First(a => a.Name == "includeRest").Value = true;
emailScope.StringVariables.First(a => a.Name == "otherNoun").Value = "seed";
var output = service.FinalizeTemplate(emailScope);
Assert.AreEqual("Don't judge each day by the harvest you reap, but by the seeds that you plant. Yes, seeds.", output.PlainEmailBody);
}
示例9: CombineVariablesTest
public void CombineVariablesTest()
{
const string plainInput =
"Don't {{verb}} each {{#repeater}}and every {{/repeater}}{{time}} by the {{noun}} you reap{{#includeRest}}, but by the {{otherNoun}}s that you plant{{/includeRest}}.";
const string htmlInput =
"<html><head></head><body><h1>Don't</h1> {{verb}} each {{#repeater}}and every {{/repeater}}{{time}}.</body></html>";
var template = new Template
{
Subject = "This is my {{noun}}",
HtmlTemplate = htmlInput,
TextTemplate = plainInput
};
var service = new Parser();
var emailScope = service.InitializeEmail(template);
emailScope.StringVariables.First(a => a.Name == "verb").Value = "judge";
emailScope.BooleanLogics.First(a => a.Name == "repeater").Value = false;
emailScope.StringVariables.First(a => a.Name == "time").Value = "day";
emailScope.StringVariables.First(a => a.Name == "noun").Value = "harvest";
emailScope.BooleanLogics.First(a => a.Name == "includeRest").Value = true;
emailScope.StringVariables.First(a => a.Name == "otherNoun").Value = "seed";
var output = service.FinalizeTemplate(emailScope);
Assert.AreEqual("Don't judge each day by the harvest you reap, but by the seeds that you plant.", output.PlainEmailBody);
Assert.AreEqual("<html><head></head><body><h1>Don't</h1> judge each day.</body></html>", output.HtmlEmailBody);
Assert.AreEqual("This is my harvest", output.Subject);
}
示例10: HtmlParseWithNoTagsShouldYieldExpectedOutcome
public void HtmlParseWithNoTagsShouldYieldExpectedOutcome()
{
const string input = "<html><h1>Four scope and seven years ago...";
var template = new Template
{
HtmlTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
var output = service.FinalizeTemplate(result);
Assert.AreEqual("<html><h1>Four scope and seven years ago...", output.HtmlEmailBody);
}
示例11: ShouldReturnTwoBooleanAndTwoVariablesWithSomeDescriptions
public void ShouldReturnTwoBooleanAndTwoVariablesWithSomeDescriptions()
{
const string input =
"Back in the 4th of {{month|Month in the year}}, there {{#ifSingular}}was{{/ifSingular}}{{#ifPlural|Changes the tense}}were{{/ifPlural}} {{count}} different ways of doing things.";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
Assert.IsTrue(result.BooleanLogics.Count == 2);
Assert.IsTrue(result.StringVariables.Count == 2);
Assert.IsTrue(result.StringVariables.Any(a => a.Name == "month"));
Assert.IsTrue(result.StringVariables.First(a => a.Name == "month").Description == "Month in the year");
Assert.IsTrue(result.StringVariables.Any(a => a.Name == "count"));
Assert.IsTrue(result.StringVariables.First(a => a.Name == "count").Description == "");
Assert.IsTrue(result.BooleanLogics.Any(a => a.Name == "ifSingular"));
Assert.IsTrue(result.BooleanLogics.First(a => a.Name == "ifSingular").Description == "");
Assert.IsTrue(result.BooleanLogics.Any(a => a.Name == "ifPlural"));
Assert.IsTrue(result.BooleanLogics.First(a => a.Name == "ifPlural").Description == "Changes the tense");
}