Exemple #1
0
        /// <inheritdoc />
        public DiffSet Diff(NodeElement expected, IXmlPathStrict path, IXmlPathStrict pathExpected, Options options)
        {
            if (expected == null)
            {
                throw new ArgumentNullException("expected");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (pathExpected == null)
            {
                throw new ArgumentNullException("pathExpected");
            }

            if (!AreNamesEqual(expected.Name, options))
            {
                return(new DiffSetBuilder()
                       .Add(new Diff(DiffType.MismatchedElement, path.Element(Index), DiffTargets.Both))
                       .ToDiffSet());
            }

            return(new DiffSetBuilder()
                   .Add(attributes.Diff(expected.Attributes, path.Element(Index), pathExpected.Element(expected.Index), options))
                   .Add(Children.Diff(expected.Children, path.Element(Index), pathExpected.Element(expected.Index), options))
                   .ToDiffSet());
        }
Exemple #2
0
        /// <inheritdoc />
        public override DiffSet Diff(INode expected, IXmlPathStrict path, IXmlPathStrict pathExpected, Options options)
        {
            var expectedComment = expected as NodeComment;

            if (expectedComment != null)
            {
                return(Diff(expectedComment, path, pathExpected, options));
            }

            return(new DiffSetBuilder()
                   .Add(new Diff(DiffType.UnexpectedComment, path.Element(Index), DiffTargets.Actual))
                   .ToDiffSet());
        }
Exemple #3
0
        /// <inheritdoc />
        public DiffSet Diff(NodeComment expected, IXmlPathStrict path, IXmlPathStrict pathExpected, Options options)
        {
            if (expected == null)
            {
                throw new ArgumentNullException("expected");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (pathExpected == null)
            {
                throw new ArgumentNullException("pathExpected");
            }

            if (((options & Options.IgnoreComments) != 0) || Text.Equals(expected.Text))
            {
                return(DiffSet.Empty);
            }

            return(new DiffSetBuilder()
                   .Add(new Diff(DiffType.MismatchedComment, path.Element(Index), DiffTargets.Both))
                   .ToDiffSet());
        }
Exemple #4
0
 /// <summary>
 /// Starts a new strict XML path by specifying the index of its root element.
 /// </summary>
 /// <param name="index">The index of the root element.</param>
 /// <returns>A new open loose XML path.</returns>
 /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is negative.</exception>
 internal static IXmlPathStrict Element(int index)
 {
     return(Empty.Element(index));
 }