A wrapper class for an XML element, usually from the specification or the target of the specification
 private void OnExceptionCaught(Element element, Exception exception, string expression)
 {
     if (ExceptionCaught != null)
     {
         ExceptionCaught(this, new ExceptionCaughtEventArgs { Element = element, Exception = exception, Expression = expression });
     }
 } 
 private void OnFailureReported(Element element, object actual, string expected)
 {
     if (FailureReported != null)
     {
         FailureReported(this, new FailureReportedEventArgs { Element = element, Actual = actual, Expected = expected });
     }
 }
 private void OnSuccessReported(Element element)
 {
     if (SuccessReported != null)
     {
         SuccessReported(this, new SuccessReportedEventArgs { Element = element });
     }
 }
Ejemplo n.º 4
0
 private void OnIgnoredRunReported(Element element)
 {
     if (IgnoredRunReported != null)
     {
         IgnoredRunReported(this, new RunResultEventArgs { Element = element });
     }
 }
Ejemplo n.º 5
0
 public void AnnounceExecuteCompleted(Element element)
 {
     foreach (var listener in m_Listeners)
     {
         listener.ExecuteCompleted(new ExecuteEvent(element));
     }
 }
Ejemplo n.º 6
0
 private void OnFailedRunReported(Element element)
 {
     if (FailedRunReported != null)
     {
         FailedRunReported(this, new RunResultEventArgs { Element = element });
     }
 }
Ejemplo n.º 7
0
 protected void AnnounceSuccess(Element element)
 {
     foreach (var assertListener in m_Listeners)
     {
         assertListener.SuccessReported(new AssertSuccessEvent(element));
     }
 }
 private void OnSurplusRow(Element element)
 {
     if (SurplusRowFound != null)
     {
         SurplusRowFound(this, new SurplusRowEventArgs { RowElement = element });
     }
 }
 private void OnSpecificationCommandProcessed(Resource resource, Element element)
 {
     if (SpecificationCommandProcessed != null)
     {
         SpecificationCommandProcessed(this, new SpecificationEventArgs { Element = element, Resource = resource });
     }
 }
        public void FailureReportedEventHandler(object sender, global::Concordion.Internal.Commands.FailureReportedEventArgs e)
        {
            Element element = e.Element;
            element.AddStyleClass("failure");

            Element spanExpected = new Element("del");
            spanExpected.AddStyleClass("expected");
            element.MoveChildrenTo(spanExpected);
            element.AppendChild(spanExpected);
            spanExpected.AppendNonBreakingSpaceIfBlank();

            Element spanActual = new Element("ins");
            spanActual.AddStyleClass("actual");
            if (e.Actual != null)
            {
                spanActual.AppendText(e.Actual.ToString());
            }
            else
            {
                spanActual.AppendText("(null)");
            }
            spanActual.AppendNonBreakingSpaceIfBlank();

            element.AppendText("\n");
            element.AppendChild(spanActual);
        }
 private void OnMissingRow(Element element)
 {
     if (MissingRowFound != null)
     {
         MissingRowFound(this, new MissingRowEventArgs { RowElement = element });
     }
 }
Ejemplo n.º 12
0
 private void OnSuccessfulRunReported(Element element)
 {
     if (SuccessfulRunReported != null)
     {
         SuccessfulRunReported(this, new RunResultEventArgs { Element = element });
     }
 }
Ejemplo n.º 13
0
 protected void AnnounceFailure(Element element, String expected, Object actual)
 {
     foreach (var assertListener in m_Listeners)
     {
         assertListener.FailureReported(new AssertFailureEvent(element, expected, actual));
     }
 }
        private void AddFooterToDocument(Element rootElement, Resource resource, long timeTaken)
        {
            Element body = rootElement.GetFirstChildElement("body");

            if (body != null)
            {

                Element footer = new Element("div");
                footer.AddStyleClass("footer");
                footer.AppendText("Results generated by ");

                Element link = new Element("a");
                link.AddAttribute("href", CONCORDION_WEBSITE_URL);
                footer.AppendChild(link);

                Element img = new Element("img");
                img.AddAttribute("src", resource.GetRelativePath(TARGET_LOGO_RESOURCE));
                img.AddAttribute("alt", "Concordion");
                img.AddAttribute("border", "0");
                link.AppendChild(img);

                Element dateDiv = new Element("div");
                dateDiv.AddStyleClass("testTime");
                dateDiv.AppendText("in " + (timeTaken + 1) + " ms ");
                dateDiv.AppendText(DateTime.Now.ToString());
                footer.AppendChild(dateDiv);

                body.AppendChild(footer);
            }
        }
 private void AnnounceBeforeProcessingEvent(Resource resource, Element element)
 {
     foreach (var listener in m_Listeners)
     {
         listener.BeforeProcessingSpecification(new SpecificationProcessingEvent(resource, element));
     }
 }
Ejemplo n.º 16
0
 public CommandCall(ICommand command, Element element, string expression, Resource resource)
 {
     Children = new CommandCallList();
     Command = command;
     Element = element;
     Expression = expression;
     Resource = resource;
 } 
 private Element ExpectedSpan(Element element)
 {
     Element spanExpected = new Element("del").AddStyleClass("expected");
     element.MoveChildrenTo(spanExpected);
     spanExpected.AppendNonBreakingSpaceIfBlank();
     Element spanFailure = new Element("span").AddStyleClass("failure");
     spanFailure.AppendChild(spanExpected);
     return spanFailure;
 }
Ejemplo n.º 18
0
        public Table(Element element)
        {
            if (!element.IsNamed("table"))
            {
                throw new ArgumentException("This strategy can only work on table elements", "element");
            }

            TableElement = element;
        } 
 private void PrependBreadcrumb(Element span, Element breadcrumb)
 {
     if (span.HasChildren)
     {
         span.PrependText(" ");
     }
     span.PrependText(" >");
     span.PrependChild(breadcrumb);
 }
Ejemplo n.º 20
0
 public void BeforeParsing(XDocument document)
 {
     var rootElement = new Element(document.Root);
     var existingValue = rootElement.GetAttributeValue(FakeExtensionAttrName);
     var newValue = this.m_Text;
     if (existingValue != null) {
         newValue = existingValue + ", " + newValue;
     }
     rootElement.AddAttribute(FakeExtensionAttrName, newValue);
 }
 private Element GetDocumentBody(Element rootElement)
 {
     Element body = rootElement.GetFirstDescendantNamed("body");
     if (body == null)
     {
         body = new Element("body");
         rootElement.AppendChild(body);
     }
     return body;
 }
 private string getHref(Element element)
 {
     string href = element.GetAttributeValue("href");
     if (href == null)
     {
         Element a = element.GetFirstChildElement("a");
         if (a != null)
         {
             href = a.GetAttributeValue("href");
         }
     }
     return href;
 }
Ejemplo n.º 23
0
        public int GetIndexOfCell(Element element)
        {
            int index = 0;
            foreach (var cell in RowElement.GetChildElements())
            {
                if (element.Text == cell.Text)
                {
                    return index;
                }
                index++;
            }

            return -1;
        }
Ejemplo n.º 24
0
        public string markAsException(string fragment, string expression, string errorMessage)
        {
            var exception = new StackTraceSettingException(errorMessage);
            exception.StackTraceElements.AddRange(stackTraceElements);

            var document = new TestRig()
                                .ProcessFragment(fragment)
                                .GetXDocument();

            var element = new Element(document.Descendants("p").ToArray()[0]);

            new ExceptionRenderer().ExceptionCaught(new ExceptionCaughtEvent(exception, element, expression));

            return element.ToXml();
        }
Ejemplo n.º 25
0
        public void SpecificationProcessedEventHandler(object sender, SpecificationEventArgs eventArgs)
        {
            try
            {
                Element span = new Element("span").AddStyleClass("breadcrumbs");
                AppendBreadcrumbsTo(span, eventArgs.Resource);

                if (span.HasChildren)
                {
                    GetDocumentBody(eventArgs.Element).PrependChild(span);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 26
0
        public void AfterProcessingSpecification(SpecificationProcessingEvent processingEvent)
        {
            try
            {
                Element span = new Element("span").AddStyleClass("breadcrumbs");
                this.AppendBreadcrumbsTo(span, processingEvent.Resource);

                if (span.HasChildren)
                {
                    this.GetDocumentBody(processingEvent.RootElement).PrependChild(span);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 27
0
        public void ExceptionCaught(ExceptionCaughtEvent caughtEvent)
        {
            this.buttonId++;
            var element = caughtEvent.Element;
            element.AppendChild(this.ExpectedSpan(element));
            // Special handling for <a> tags to avoid the stack-trace being inside the link text
            if (element.IsNamed("a"))
            {
                var div = new Element("div");
                element.AppendSister(div);
                element = div;
            }
            element.AppendChild(this.ExceptionMessage(caughtEvent.CaughtException.Message));
            element.AppendChild(this.StackTraceTogglingButton());
            element.AppendChild(this.StackTrace(caughtEvent.CaughtException, caughtEvent.Expression));

            this.EnsureDocumentHasTogglingScript(element);
        }
Ejemplo n.º 28
0
        public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
        {
            Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'echo' is not supported");

            Object result = evaluator.Evaluate(commandCall.Expression);

            Element element = commandCall.Element;
            if (result != null)
            {
                element.AppendText(result.ToString());
            }
            else
            {
                Element child = new Element("em");
                child.AppendText("null");
                element.AppendChild(child);
            }
        }
Ejemplo n.º 29
0
        private void EnsureDocumentHasTogglingScript(Element element)
        {
            Element rootElement = element.GetRootElement();

            if (!RootElementsWithScript.Contains(rootElement))
            {
                RootElementsWithScript.Add(rootElement);
                Element head = rootElement.GetFirstDescendantNamed("head");
                if (head == null)
                {
                    Console.WriteLine(rootElement.ToXml());
                }
                Check.NotNull(head, "Document <head> section is missing");
                Element script = new Element("script").AddAttribute("type", "text/javascript");
                head.PrependChild(script);
                script.AppendText(HtmlFramework.TOGGLING_SCRIPT_RESOURCE);
            }
        }
        public void FailureReported(AssertFailureEvent failureEvent)
        {
            var element = failureEvent.Element;
            element.AddStyleClass("failure");

            var spanExpected = new Element("del");
            spanExpected.AddStyleClass("expected");
            element.MoveChildrenTo(spanExpected);
            element.AppendChild(spanExpected);
            spanExpected.AppendNonBreakingSpaceIfBlank();

            var spanActual = new Element("ins");
            spanActual.AddStyleClass("actual");
            spanActual.AppendText(failureEvent.Actual != null ? failureEvent.Actual.ToString() : "(null)");
            spanActual.AppendNonBreakingSpaceIfBlank();

            element.AppendText("\n");
            element.AppendChild(spanActual);
        }