本文整理汇总了C#中PicklesDoc.Pickles.ObjectModel.Feature.AddFeatureElement方法的典型用法代码示例。如果您正苦于以下问题:C# Feature.AddFeatureElement方法的具体用法?C# Feature.AddFeatureElement怎么用?C# Feature.AddFeatureElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PicklesDoc.Pickles.ObjectModel.Feature
的用法示例。
在下文中一共展示了Feature.AddFeatureElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Then_feature_without_background_adds_first_scenario_on_correct_row
public void Then_feature_without_background_adds_first_scenario_on_correct_row()
{
var excelFeatureFormatter = Container.Resolve<ExcelFeatureFormatter>();
var feature = new Feature
{
Name = "Test Feature",
Description =
"In order to test this feature,\nAs a developer\nI want to test this feature",
};
var scenario = new Scenario
{
Name = "Test Scenario",
Description =
"In order to test this scenario,\nAs a developer\nI want to test this scenario"
};
var given = new Step { NativeKeyword = "Given", Name = "a precondition" };
scenario.Steps = new List<Step>(new[] { given });
feature.AddFeatureElement(scenario);
using (var workbook = new XLWorkbook())
{
IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
excelFeatureFormatter.Format(worksheet, feature);
Check.That(worksheet.Cell("B4").Value).IsEqualTo(scenario.Name);
Check.That(worksheet.Cell("C5").Value).IsEqualTo(scenario.Description);
Check.That(worksheet.Cell("D6").Value).IsEqualTo(given.Name);
}
}
示例2: MapToFeature
public Feature MapToFeature(G.GherkinDocument gherkinDocument)
{
if (gherkinDocument == null)
{
return null;
}
var feature = new Feature();
var background = gherkinDocument.Feature.Children.SingleOrDefault(c => c is G.Background) as G.Background;
if (background != null)
{
feature.AddBackground(this.MapToScenario(background));
}
if (this.configuration.ShouldEnableComments)
{
feature.Comments.AddRange((gherkinDocument.Comments ?? new G.Comment[0]).Select(this.MapToComment));
}
feature.Description = gherkinDocument.Feature.Description ?? string.Empty;
foreach (var featureElement in gherkinDocument.Feature.Children.Where(c => !(c is G.Background)))
{
feature.AddFeatureElement(this.MapToFeatureElement(featureElement));
}
feature.Name = gherkinDocument.Feature.Name;
foreach (var tag in gherkinDocument.Feature.Tags)
{
feature.AddTag(this.MapToString(tag));
}
foreach (var comment in feature.Comments.ToArray())
{
// Find the related feature
var relatedFeatureElement = feature.FeatureElements.LastOrDefault(x => x.Location.Line < comment.Location.Line);
// Find the step to which the comment is related to
if (relatedFeatureElement != null)
{
var stepAfterComment = relatedFeatureElement.Steps.FirstOrDefault(x => x.Location.Line > comment.Location.Line);
if (stepAfterComment != null)
{
// Comment is before a step
comment.Type = CommentType.StepComment;
stepAfterComment.Comments.Add(comment);
}
else
{
// Comment is located after the last step
var stepBeforeComment = relatedFeatureElement.Steps.LastOrDefault(x => x.Location.Line < comment.Location.Line);
if (stepBeforeComment != null && stepBeforeComment == relatedFeatureElement.Steps.Last())
{
comment.Type = CommentType.AfterLastStepComment;
stepBeforeComment.Comments.Add(comment);
}
}
}
}
foreach (var featureElement in feature.FeatureElements.ToArray())
{
featureElement.Feature = feature;
}
if (feature.Background != null)
{
feature.Background.Feature = feature;
}
return feature;
}