Esempio n. 1
0
        private XElement FormatHeading(ScenarioOutline scenarioOutline)
        {
            if (string.IsNullOrEmpty(scenarioOutline.Name))
            {
                return(null);
            }

            var result = new XElement(
                this.xmlns + "div",
                new XAttribute("class", "scenario-heading"),
                string.IsNullOrEmpty(scenarioOutline.Slug) ? null : new XAttribute("id", scenarioOutline.Slug)
                );

            var tags = RetrieveTags(scenarioOutline);

            if (tags.Length > 0)
            {
                var paragraph = new XElement(this.xmlns + "p", HtmlScenarioFormatter.CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns));
                paragraph.Add(new XAttribute("class", "tags"));
                result.Add(paragraph);
            }

            result.Add(new XElement(this.xmlns + "h2", scenarioOutline.Name));

            result.Add(this.htmlDescriptionFormatter.Format(scenarioOutline.Description));

            return(result);
        }
Esempio n. 2
0
 public HtmlFeatureFormatter(
     HtmlScenarioFormatter htmlScenarioFormatter,
     HtmlDescriptionFormatter htmlDescriptionFormatter,
     HtmlScenarioOutlineFormatter htmlScenarioOutlineFormatter,
     HtmlImageResultFormatter htmlImageResultFormatter)
 {
     this.htmlScenarioFormatter        = htmlScenarioFormatter;
     this.htmlScenarioOutlineFormatter = htmlScenarioOutlineFormatter;
     this.htmlDescriptionFormatter     = htmlDescriptionFormatter;
     this.htmlImageResultFormatter     = htmlImageResultFormatter;
     this.xmlns = HtmlNamespace.Xhtml;
 }
Esempio n. 3
0
        public XElement Format(Feature feature)
        {
            var div = new XElement(
                this.xmlns + "div",
                new XAttribute("id", "feature"),
                this.htmlImageResultFormatter.Format(feature));

            var tags = RetrieveTags(feature);

            if (tags.Length > 0)
            {
                var paragraph = new XElement(this.xmlns + "p", HtmlScenarioFormatter.CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns));
                paragraph.Add(new XAttribute("class", "tags"));
                div.Add(paragraph);
            }

            div.Add(new XElement(this.xmlns + "h1", feature.Name));

            div.Add(this.htmlDescriptionFormatter.Format(feature.Description));

            var scenarios = new XElement(this.xmlns + "ul", new XAttribute("id", "scenarios"));
            int id        = 0;

            if (feature.Background != null)
            {
                scenarios.Add(this.htmlScenarioFormatter.Format(feature.Background, id++));
            }

            foreach (IFeatureElement featureElement in feature.FeatureElements)
            {
                var scenario = featureElement as Scenario;
                if (scenario != null)
                {
                    scenarios.Add(this.htmlScenarioFormatter.Format(scenario, id++));
                }

                var scenarioOutline = featureElement as ScenarioOutline;
                if (scenarioOutline != null)
                {
                    scenarios.Add(this.htmlScenarioOutlineFormatter.Format(scenarioOutline, id++));
                }
            }

            div.Add(scenarios);

            return(div);
        }
Esempio n. 4
0
        private XElement FormatExamples(ScenarioOutline scenarioOutline)
        {
            var exampleDiv = new XElement(this.xmlns + "div");

            var languageServices = this.languageServicesRegistry.GetLanguageServicesForLanguage(scenarioOutline.Feature?.Language);

            foreach (var example in scenarioOutline.Examples)
            {
                exampleDiv.Add(
                    new XElement(
                        this.xmlns + "div",
                        new XAttribute("class", "examples"),
                        (example.Tags == null || example.Tags.Count == 0) ? null : new XElement(this.xmlns + "p", new XAttribute("class", "tags"), HtmlScenarioFormatter.CreateTagElements(example.Tags.OrderBy(t => t).ToArray(), this.xmlns)),
                        new XElement(this.xmlns + "h3", languageServices.ExamplesKeywords[0] + ": " + example.Name),
                        this.htmlDescriptionFormatter.Format(example.Description),
                        (example.TableArgument == null) ? null : this.htmlTableFormatter.Format(example.TableArgument, scenarioOutline)));
            }

            return(exampleDiv);
        }