public void Setup()
        {
            this._testFeature = new Feature {Name = "Test"};
            this._featureFileInfo = new FileInfo(Path.Combine(ROOT_PATH, FEATURE_PATH));
            this._featureDirectoryNode = new FeatureDirectoryTreeNode(this._featureFileInfo, RELATIVE_PATH, this._testFeature);

            this._featureWithMeta = new FeatureWithMetaInfo(this._featureDirectoryNode);
        }
Example #2
0
 private static void SetResultsForIndividualScenariosUnderFeature(FeatureDirectoryTreeNode 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 FeatureDirectoryTreeNode(new FileInfo(@"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(FeatureDirectoryTreeNode 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 =
                new FileInfo(Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot)).
                    Directory.FullName.ToLowerInvariant();
            if (!Directory.Exists(relativePath)) Directory.CreateDirectory(relativePath);
            Uri relativeFilePath = ditaMapPathGenerator.GeneratePathToFeature(featureNode);
            string filename = Path.Combine(relativePath, 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 formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, Container.Resolve<HtmlIndexFormatter>());

            var featureNode = new FeatureDirectoryTreeNode(
                new FileInfo(@"c:\temp\test.feature"),
                ".",
                new Feature());

            formatter.Format(featureNode, new IDirectoryTreeNode[0]);

            fakeHtmlFeatureFormatter.Verify(f => f.Format(featureNode.Feature));
        }
        public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument()
        {
            var fakeHtmlFeatureFormatter = new Mock<IHtmlFeatureFormatter>();
            var fakeHtmlImageRelocator = new Mock<HtmlImageRelocator>(null);
            fakeHtmlImageRelocator.Setup(x => x.Relocate(It.IsAny<IDirectoryTreeNode>(), It.IsAny<XElement>()));
            var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, Container.Resolve<HtmlIndexFormatter>(), fakeHtmlImageRelocator.Object);

            var featureNode = new FeatureDirectoryTreeNode(
                new FileInfo(@"c:\temp\test.feature"),
                ".",
                new Feature());

            formatter.Format(featureNode, new IDirectoryTreeNode[0]);

            fakeHtmlFeatureFormatter.Verify(f => f.Format(featureNode.Feature));
        }
        public void Format(Body body, FeatureDirectoryTreeNode featureDirectoryTreeNode)
        {
            Feature feature = featureDirectoryTreeNode.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);

            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, FeatureDirectoryTreeNode featureChildNode)
 {
     return workbook.Worksheets.FirstOrDefault(
         sheet => sheet.Cell("A1").Value.ToString() == featureChildNode.Feature.Name);
 }
Example #9
0
 private static void SetResultsAtFeatureLevel(FeatureDirectoryTreeNode featureTreeNode, ITestResults testResults)
 {
     featureTreeNode.Feature.Result = testResults.GetFeatureResult(featureTreeNode.Feature);
 }