本文整理汇总了C#中Scenario类的典型用法代码示例。如果您正苦于以下问题:C# Scenario类的具体用法?C# Scenario怎么用?C# Scenario使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Scenario类属于命名空间,在下文中一共展示了Scenario类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public void Format(Body body, Scenario background)
{
var headerParagraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading2" }));
var backgroundKeyword = GetLocalizedBackgroundKeyword();
headerParagraph.Append(new Run(new RunProperties(new Bold()), new Text(backgroundKeyword)));
var table = new Table();
table.Append(GenerateTableProperties());
var row = new TableRow();
var cell = new TableCell();
cell.Append(headerParagraph);
foreach (var descriptionSentence in WordDescriptionFormatter.SplitDescription(background.Description))
{
cell.Append(CreateNormalParagraph(descriptionSentence));
}
foreach (var step in background.Steps)
{
cell.Append(WordStepFormatter.GenerateStepParagraph(step));
}
cell.Append(CreateNormalParagraph("")); // Is there a better way to generate a new empty line?
row.Append(cell);
table.Append(row);
body.Append(table);
}
示例2: Format
public void Format(XElement parentElement, Scenario scenario)
{
var section = new XElement("section",
new XElement("title", scenario.Name));
if (this.configuration.HasTestResults)
{
TestResult testResult = this.nunitResults.GetScenarioResult(scenario);
if (testResult.WasExecuted && testResult.WasSuccessful)
{
section.Add(new XElement("note", "This scenario passed"));
}
else if (testResult.WasExecuted && !testResult.WasSuccessful)
{
section.Add(new XElement("note", "This scenario failed"));
}
}
if (!string.IsNullOrEmpty(scenario.Description))
{
section.Add(new XElement("p", scenario.Description));
}
foreach (Step step in scenario.Steps)
{
this.ditaStepFormatter.Format(section, step);
}
parentElement.Add(section);
}
示例3: Scenario
/// <summary>
/// Create a new scenario with the given title, ensuring the previous scenario was properly
/// cleaned up. Suggested if you use MBUnit or NUnit to
/// create a base class with a method 'Scenario()' which uses the current test's naame. E.g.
///
/// protected Scenario(){
/// return Scenario(TestContext.CurrentContext.Test.Name);
/// }
/// </summary>
/// <param name="title">the scenario title. Can not be empty or null</param>
/// <returns>a newly created scenario</returns>
public Scenario Scenario(String title)
{
//ensure previous scenario has completed to prevent dangling scenarios
//i.e. those which look like they have passed but haven't actually run
if (CurrentScenario != null)
{
try
{
AfterTest();
}
catch (AssertionFailedException e)
{
throw new AssertionFailedException("Previous Scenario failed", e);
}
BeforeTest();
}
if (String.IsNullOrWhiteSpace(title))
{
TestFirstAssert.Fail("Scenario's require a title");
}
//Console.WriteLine("New Scenario:" + title);
OnBeforeNewScenario();
CurrentScenario = new Scenario(title, Injector);
return CurrentScenario;
}
示例4: ThenSingleScenarioWithStepsAddedSuccessfully
public void ThenSingleScenarioWithStepsAddedSuccessfully()
{
var excelScenarioFormatter = Container.Resolve<ExcelScenarioFormatter>();
var scenario = new Scenario
{
Name = "Test Feature",
Description =
"In order to test this feature,\nAs a developer\nI want to test this feature"
};
var given = new Step {NativeKeyword = "Given", Name = "a precondition"};
var when = new Step {NativeKeyword = "When", Name = "an event occurs"};
var then = new Step {NativeKeyword = "Then", Name = "a postcondition"};
scenario.Steps = new List<Step>(new[] {given, when, then});
using (var workbook = new XLWorkbook())
{
IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
int row = 3;
excelScenarioFormatter.Format(worksheet, scenario, ref row);
worksheet.Cell("B3").Value.ShouldEqual(scenario.Name);
worksheet.Cell("C4").Value.ShouldEqual(scenario.Description);
row.ShouldEqual(8);
}
}
示例5: GetScenarioId
public string GetScenarioId(Scenario scenario)
{
var id = string.Format("scenario-{0}", _currentScenarioNumber);
_currentScenarioNumber++;
_currentStepNumber = 1;
return id;
}
示例6: Format
public XElement Format(Scenario scenario, int id)
{
var header = new XElement(
this.xmlns + "div",
new XAttribute("class", "scenario-heading"),
new XElement(this.xmlns + "h2", scenario.Name));
var tags = RetrieveTags(scenario);
if (tags.Length > 0)
{
var paragraph = new XElement(this.xmlns + "p", CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns));
paragraph.Add(new XAttribute("class", "tags"));
header.Add(paragraph);
}
header.Add(this.htmlDescriptionFormatter.Format(scenario.Description));
return new XElement(
this.xmlns + "li",
new XAttribute("class", "scenario"),
this.htmlImageResultFormatter.Format(scenario),
header,
new XElement(
this.xmlns + "div",
new XAttribute("class", "steps"),
new XElement(
this.xmlns + "ul",
scenario.Steps.Select(step => this.htmlStepFormatter.Format(step))))
);
}
示例7: NoTags
public void NoTags()
{
var configuration = Container.Resolve<Configuration>();
configuration.TestResultsFiles = null;
var scenario = new Scenario
{
Name = "A Scenario",
Description = @"This scenario has no tags",
Tags = { }
};
var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>();
XElement featureElement = htmlFeatureFormatter.Format(scenario, 1);
XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");
Assert.NotNull(header);
header.ShouldBeNamed("div");
header.ShouldBeInInNamespace("http://www.w3.org/1999/xhtml");
header.ShouldHaveAttribute("class", "scenario-heading");
Assert.AreEqual(2, header.Elements().Count());
header.Elements().ElementAt(0).ShouldBeNamed("h2");
header.Elements().ElementAt(1).ShouldBeNamed("div");
}
示例8: Should_update_scenarioContext_with_info_from_ScenarioCreated
public void Should_update_scenarioContext_with_info_from_ScenarioCreated()
{
const string scenarioTitle = "scenario title";
var scenario = new Scenario(scenarioTitle, "", new Feature("ignored"));
sut.OnScenarioStartedEvent(scenario);
Assert.That(scenarioContext.ScenarioTitle, Is.EqualTo(scenarioTitle));
}
示例9: DictDeserialize
public override void DictDeserialize(IDictionary<string, object> docu, Scenario scenario = Scenario.Database)
{
base.DictDeserialize(docu);
TableSelector.SelectItem =
dataManager.DataCollections.FirstOrDefault(d => d.Name == docu["Table"].ToString());
TableSelector.InformPropertyChanged("");
}
示例10: Matches
protected override bool Matches(Scenario scenario)
{
RunScenario runScenario = scenario as RunScenario;
if (runScenario == null) return false;
return (mPersonality == runScenario.mPersonality);
}
示例11: ThenCanRenderTags
public void ThenCanRenderTags()
{
var configuration = Container.Resolve<Configuration>();
var scenario = new Scenario
{
Name = "A Scenario",
Description = @"This scenario has tags",
Tags = { "tag1", "tag2" }
};
var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>();
XElement featureElement = htmlFeatureFormatter.Format(scenario, 1);
XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");
Check.That(header).IsNotNull();
Check.That(header).IsNamed("div");
Check.That(header).IsInNamespace("http://www.w3.org/1999/xhtml");
Check.That(header).HasAttribute("class", "scenario-heading");
Check.That(header.Elements().Count()).IsEqualTo(3);
Check.That(header.Elements().ElementAt(0)).IsNamed("h2");
Check.That(header.Elements().ElementAt(1)).IsNamed("p");
Check.That(header.Elements().ElementAt(2)).IsNamed("div");
var tagsParagraph = header.Elements().ElementAt(1);
Check.That(tagsParagraph.ToString()).IsEqualTo(
@"<p class=""tags"" xmlns=""http://www.w3.org/1999/xhtml"">Tags: <span>tag1</span>, <span>tag2</span></p>");
}
示例12: RunBackground
private IEnumerable<StepResult> RunBackground(Scenario background)
{
return RunSteps(background.Steps, ctx => { }, ctx => { })
.Select(_ => new BackgroundStepResult(background.Title, _))
.Cast<StepResult>()
.ToList();
}
示例13: Execute
public static void Execute(Scenario scenario, Actor actor)
{
Precondition.Requires(
scenario != null,
Properties.Resources.USE_CASE_SCENARIO_CANNOT_BE_NULL
);
Precondition.Requires(
actor != null,
Properties.Resources.USE_CASE_ACTOR_CANNOT_BE_NULL
);
try
{
if (!scenario.Authorize(actor))
{
throw new AuthorizationException(Properties.Resources.USER_AUTHORIZATION_FAILED);
}
scenario.Execute();
}
catch (DomainException)
{
throw;
}
catch (Exception exc)
{
throw new DomainException(exc.Message, exc);
}
}
示例14: LoadScenario
private void LoadScenario(XmlReader reader, Scenario scenario)
{
while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement)
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Stack")
{
var stack = new Stack();
scenario.Stacks[reader.GetAttribute("name")] = stack;
var stackAttributes = new Dictionary<string, string>();
if (reader.MoveToFirstAttribute())
{
for (; ; )
{
if (reader.Name != "name")
stackAttributes.Add(reader.Name, reader.Value);
if (!reader.MoveToNextAttribute())
break;
}
reader.MoveToElement();
}
reader.ReadStartElement("Stack");
LoadStack(reader, stack);
reader.ReadEndElement();
foreach (var attr in stackAttributes)
_stackDecorator[attr.Key](stack, attr.Value);
}
else
{
reader.Read();
}
}
}
示例15: RunExamples
private ScenarioResult RunExamples(Scenario scenario)
{
var runner = new ExampleRunner();
Func<IEnumerable<StringStep>, IEnumerable<StepResult>> runSteps = steps => RunSteps(steps, BeforeStep, AfterStep);
var exampleResults = runner.RunExamples(scenario, runSteps, BeforeScenario, AfterScenario);
return exampleResults;
}