Example #1
0
        private HtmlCompareResult MatchesElement(string expected, NodeTree expectedNodeTree, IElement element)
        {
            if (_options.ElementComparisonMode == ElementComparisonMode.Element)
            {
                var expectedElement = expectedNodeTree.First();
                if (NodesAreEqual(expectedElement, element))
                {
                    return(HtmlCompareResult.Match);
                }

                return(HtmlCompareResult.Mismatch(expected, HtmlMarkupFormatter.Instance.OpenTag(element, true)));
            }

            var includeRoot     = _options.ElementComparisonMode == ElementComparisonMode.OuterHtml;
            var elementNodeTree = CreateNodeTree(element, includeRoot);

            if (NodeTreesAreEqual(expectedNodeTree, elementNodeTree))
            {
                return(HtmlCompareResult.Match);
            }

            return(HtmlCompareResult.Mismatch(expected, includeRoot ? element.OuterHtml : element.InnerHtml));
        }