Beispiel #1
0
        /// <summary>
        /// Compares an <paramref name="actual"/> <see cref="INodeList"/> with an <paramref name="expected"/>
        /// <see cref="INode"/>.
        /// </summary>
        /// <param name="actual">The node list to check.</param>
        /// <param name="expected">The node to compare with</param>
        /// <returns>Any differences found.</returns>
        public static IReadOnlyList <IDiff> CompareTo(this INodeList actual, INode expected)
        {
            if (actual is null)
            {
                throw new ArgumentNullException(nameof(actual));
            }
            if (expected is null)
            {
                throw new ArgumentNullException(nameof(expected));
            }

            var comparer = expected.GetHtmlComparer()
                           ?? actual.GetHtmlComparer()
                           ?? new HtmlComparer();

            return(comparer.Compare(expected.AsEnumerable(), actual).ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Compares an <paramref name="actual"/> <see cref="INodeList"/> with an <paramref name="expected"/>
        /// <see cref="INodeList"/>.
        /// </summary>
        /// <param name="actual">The node list to check.</param>
        /// <param name="expected">The node list to compare with</param>
        /// <returns>Any differences found.</returns>
        public static IReadOnlyList <IDiff> CompareTo(this INodeList actual, INodeList expected)
        {
            if (actual is null)
            {
                throw new ArgumentNullException(nameof(actual));
            }
            if (expected is null)
            {
                throw new ArgumentNullException(nameof(expected));
            }

            if (actual.Length == 0 && expected.Length == 0)
            {
                return(Array.Empty <IDiff>());
            }

            var comparer = actual.GetHtmlComparer()
                           ?? expected.GetHtmlComparer()
                           ?? new HtmlComparer();

            return(comparer.Compare(expected, actual).ToArray());
        }