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 ThenCanGeneratePathToDeepLevelFeatureFileSuccessfully()
        {
            var configuration = Kernel.Get<Configuration>();
            configuration.FeatureFolder = new System.IO.DirectoryInfo(@"c:\features");
            var featureNode = new FeatureDirectoryTreeNode(new FileInfo(@"c:\features\path\to\the_feature.feature"), @"features\path\to\the_feature.feature", new Feature { Name = "The Feature" });

            var ditaMapPathGenerator = Kernel.Get<DitaMapPathGenerator>();

            var existingUri = ditaMapPathGenerator.GeneratePathToFeature(featureNode);
            Assert.AreEqual(@"path/to/the_feature.dita", existingUri.OriginalString);
        }
Exemple #3
0
        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");
        }
        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 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 Format(Body body, FeatureDirectoryTreeNode featureDirectoryTreeNode)
        {
            var feature = featureDirectoryTreeNode.Feature;

            body.InsertPageBreak();

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

            foreach (var 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);
 }
 public FeatureWithMetaInfo(FeatureDirectoryTreeNode featureNodeTreeNode)
 {
     Feature = featureNodeTreeNode.Feature;
     RelativeFolder = featureNodeTreeNode.RelativePathFromRoot;
 }
Exemple #9
0
 public FeatureWithMetaInfo(FeatureDirectoryTreeNode featureNodeTreeNode, TestResult result)
     : this(featureNodeTreeNode)
 {
     Result = result;
 }