Exemplo n.º 1
0
        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 (configuration.HasTestResults)
            {
                TestResult testResult = 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)
                {
                    ditaScenarioFormatter.Format(body, scenario);
                }

                var scenarioOutline = featureElement as ScenarioOutline;
                if (scenarioOutline != null)
                {
                    ditaScenarioOutlineFormatter.Format(body, scenarioOutline);
                }
            }

            // HACK - This relative path stuff needs to be refactored
            string relativePath =
                new FileInfo(Path.Combine(configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot)).
                Directory.FullName.ToLowerInvariant();

            if (!Directory.Exists(relativePath))
            {
                Directory.CreateDirectory(relativePath);
            }
            string filename = Path.Combine(relativePath, feature.Name.ToDitaName() + ".dita");
            var    document =
                new XDocument(new XDocumentType("topic", "-//OASIS//DTD DITA Topic//EN", "topic.dtd", string.Empty),
                              topic);

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

            _featureWithMeta = new FeatureWithMetaInfo(_featureDirectoryNode);
        }
        public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument()
        {
            var fakeHtmlFeatureFormatter = new Mock <IHtmlFeatureFormatter>();
            var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, Kernel.Get <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 ThenCanGeneratePathToTopLevelFeatureFileSuccessfully()
        {
            var configuration = Kernel.Get <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 = Kernel.Get <DitaMapPathGenerator>();

            Uri existingUri = ditaMapPathGenerator.GeneratePathToFeature(featureNode);

            existingUri.OriginalString.ShouldEqual(@"the_feature.dita");
        }
Exemplo n.º 5
0
        public void Format(Body body, FeatureDirectoryTreeNode featureDirectoryTreeNode)
        {
            Feature feature = featureDirectoryTreeNode.Feature;

            body.InsertPageBreak();

            if (configuration.HasTestResults)
            {
                TestResult testResult = 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");
            body.GenerateParagraph(feature.Description, "Normal");

            foreach (IFeatureElement featureElement in feature.FeatureElements)
            {
                var scenario = featureElement as Scenario;
                if (scenario != null)
                {
                    wordScenarioFormatter.Format(body, scenario);
                }

                var scenarioOutline = featureElement as ScenarioOutline;
                if (scenarioOutline != null)
                {
                    wordScenarioOutlineFormatter.Format(body, scenarioOutline);
                }
            }
        }
Exemplo n.º 6
0
 private static IXLWorksheet FindFirstMatchingA1TitleUsingFeatureName(XLWorkbook workbook, FeatureDirectoryTreeNode featureChildNode)
 {
     return(workbook.Worksheets.FirstOrDefault(
                sheet => sheet.Cell("A1").Value.ToString() == featureChildNode.Feature.Name));
 }
Exemplo n.º 7
0
 public FeatureWithMetaInfo(FeatureDirectoryTreeNode featureNodeTreeNode)
 {
     Feature        = featureNodeTreeNode.Feature;
     RelativeFolder = featureNodeTreeNode.RelativePathFromRoot;
 }
Exemplo n.º 8
0
 public FeatureWithMetaInfo(FeatureDirectoryTreeNode featureNodeTreeNode, TestResult result)
     : this(featureNodeTreeNode)
 {
     Result = result;
 }