public JsonFeatureWithMetaInfo(FeatureNode featureNodeTreeNode, TestResult result) { var jsonMapper = new JsonMapper(); this.Feature = jsonMapper.Map(featureNodeTreeNode.Feature); this.RelativeFolder = featureNodeTreeNode.RelativePathFromRoot; this.Result = jsonMapper.Map(result); }
public void Setup() { this.testFeature = new Feature { Name = "Test" }; this.featureFileInfo = this.FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine(RootPath, FeaturePath)); this.featureDirectoryNode = new FeatureNode(this.featureFileInfo, RelativePath, this.testFeature); this.featureWithMeta = new JsonFeatureWithMetaInfo(this.featureDirectoryNode); }
public void Setup() { this._testFeature = new Feature { Name = "Test" }; this._featureFileInfo = this.FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine(ROOT_PATH, FEATURE_PATH)); this._featureDirectoryNode = new FeatureNode(this._featureFileInfo, RELATIVE_PATH, this._testFeature); this._featureWithMeta = new FeatureWithMetaInfo(this._featureDirectoryNode); }
private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults) { foreach (var scenario in featureTreeNode.Feature.FeatureElements) { scenario.Result = scenario.GetType().Name == "Scenario" ? testResults.GetScenarioResult(scenario as Scenario) : testResults.GetScenarioOutlineResult(scenario as ScenarioOutline); } }
public void ThenCanGeneratePathToTopLevelFeatureFileSuccessfully() { var configuration = Container.Resolve<Configuration>(); configuration.FeatureFolder = new DirectoryInfo(@"c:\features"); var featureNode = new FeatureNode(FileSystem.FileInfo.FromFileName(@"c:\features\the_feature.feature"), @"features\the_feature.feature", new Feature {Name = "The Feature"}); var ditaMapPathGenerator = Container.Resolve<DitaMapPathGenerator>(); Uri existingUri = ditaMapPathGenerator.GeneratePathToFeature(featureNode); existingUri.OriginalString.ShouldEqual(@"the_feature.dita"); }
public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument() { var fakeHtmlFeatureFormatter = new Mock<IHtmlFeatureFormatter>(); var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, new HtmlIndexFormatter()); var featureNode = new FeatureNode( FileSystem.FileInfo.FromFileName(@"c:\temp\test.feature"), ".", new Feature()); formatter.Format(featureNode, new INode[0]); fakeHtmlFeatureFormatter.Verify(f => f.Format(featureNode.Feature)); }
public void Format(FeatureNode featureNode) { Feature feature = featureNode.Feature; var topic = new XElement("topic", new XAttribute("id", feature.Name.ToDitaName())); topic.Add(new XElement("title", feature.Name)); topic.Add(new XElement("shortdesc", feature.Description)); var body = new XElement("body"); topic.Add(body); if (this.configuration.HasTestResults) { TestResult testResult = this.nunitResults.GetFeatureResult(feature); if (testResult.WasExecuted && testResult.WasSuccessful) { body.Add(new XElement("note", "This feature passed")); } else if (testResult.WasExecuted && !testResult.WasSuccessful) { body.Add(new XElement("note", "This feature failed")); } } foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { this.ditaScenarioFormatter.Format(body, scenario); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { this.ditaScenarioOutlineFormatter.Format(body, scenarioOutline); } } // HACK - This relative path stuff needs to be refactored string relativePath = this.fileSystem.FileInfo.FromFileName(this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot)).Directory.FullName.ToLowerInvariant(); if (!this.fileSystem.Directory.Exists(relativePath)) this.fileSystem.Directory.CreateDirectory(relativePath); Uri relativeFilePath = ditaMapPathGenerator.GeneratePathToFeature(featureNode); string filename = this.fileSystem.Path.Combine(relativePath, this.fileSystem.Path.GetFileName(relativeFilePath.ToString())); var document = new XDocument(new XDocumentType("topic", "-//OASIS//DTD DITA Topic//EN", "topic.dtd", string.Empty), topic); document.Save(filename); }
public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument() { var fakeHtmlFeatureFormatter = new Mock<IHtmlFeatureFormatter>(); var fakeHtmlImageRelocator = new Mock<HtmlImageRelocator>(null, null); fakeHtmlImageRelocator.Setup(x => x.Relocate(It.IsAny<INode>(), It.IsAny<XElement>())); var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, Container.Resolve<HtmlIndexFormatter>(), fakeHtmlImageRelocator.Object); var featureNode = new FeatureNode( FileSystem.FileInfo.FromFileName(@"c:\temp\test.feature"), ".", new Feature()); formatter.Format(featureNode, new INode[0]); fakeHtmlFeatureFormatter.Verify(f => f.Format(featureNode.Feature)); }
public void Format(Body body, FeatureNode featureNode) { Feature feature = featureNode.Feature; body.InsertPageBreak(); if (this.configuration.HasTestResults) { TestResult testResult = this.nunitResults.GetFeatureResult(feature); if (testResult.WasExecuted && testResult.WasSuccessful) { body.GenerateParagraph("Passed", "Passed"); } else if (testResult.WasExecuted && !testResult.WasSuccessful) { body.GenerateParagraph("Failed", "Failed"); } } body.GenerateParagraph(feature.Name, "Heading1"); this.wordDescriptionFormatter.Format(body, feature.Description); if (feature.Background != null) { this.wordBackgroundFormatter.Format(body, feature.Background); } foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { this.wordScenarioFormatter.Format(body, scenario); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { this.wordScenarioOutlineFormatter.Format(body, scenarioOutline); } } }
private static IXLWorksheet FindFirstMatchingA1TitleUsingFeatureName(XLWorkbook workbook, FeatureNode featureChildNode) { return workbook.Worksheets.FirstOrDefault( sheet => sheet.Cell("A1").Value.ToString() == featureChildNode.Feature.Name); }
private static void SetResultsAtFeatureLevel(FeatureNode featureTreeNode, ITestResults testResults) { featureTreeNode.Feature.Result = testResults.GetFeatureResult(featureTreeNode.Feature); }
private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults) { foreach (var featureElement in featureTreeNode.Feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { featureElement.Result = testResults.GetScenarioResult(scenario); continue; } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { if (testResults.SupportsExampleResults) { foreach (var example in scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows)) { example.Result = testResults.GetExampleResult(scenarioOutline, example.ToArray()); } scenarioOutline.Result = scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows).Select(row => row.Result).Merge(); } else { featureElement.Result = testResults.GetScenarioOutlineResult(scenarioOutline); } continue; } } }
public JsonFeatureWithMetaInfo(FeatureNode featureNodeTreeNode) : this(featureNodeTreeNode, default(TestResult)) { }
public FeatureWithMetaInfo(FeatureNode featureNodeTreeNode) { this.Feature = featureNodeTreeNode.Feature; this.RelativeFolder = featureNodeTreeNode.RelativePathFromRoot; }
public FeatureWithMetaInfo(FeatureNode featureNodeTreeNode, TestResult result) : this(featureNodeTreeNode) { this.Result = result; }