public static void ShouldBeTextChange(this IDiff actualChange, IRenderedFragment expectedChange, string?userMessage = null) { if (expectedChange is null) { throw new ArgumentNullException(nameof(expectedChange)); } ShouldBeTextChange(actualChange, expectedChange.GetNodes(), userMessage); }
/// <summary> /// Verifies that the <paramref name="actual"/> <see cref="INode"/> matches /// the rendered markup from the <paramref name="expected"/> <see cref="IRenderedFragment"/>, using the <see cref="HtmlComparer"/> /// type. /// </summary> /// <exception cref="HtmlEqualException">Thrown when the <paramref name="actual"/> markup does not match the <paramref name="expected"/> markup.</exception> /// <param name="actual">The node to verify.</param> /// <param name="expected">The expected rendered fragment.</param> /// <param name="userMessage">A custom user message to display in case the verification fails.</param> public static void MarkupMatches(this INode actual, IRenderedFragment expected, string?userMessage = null) { if (actual is null) { throw new ArgumentNullException(nameof(actual)); } if (expected is null) { throw new ArgumentNullException(nameof(expected)); } actual.MarkupMatches(expected.GetNodes(), userMessage); }
/// <summary> /// Compare the rendered markup in the <paramref name="actual"/> <see cref = "IRenderedFragment" /> to /// the rendered markup in the <paramref name="expected"/> <see cref = "IRenderedFragment" /> /// </summary> /// <param name="actual">Source of rendered markup to check.</param> /// <param name="expected">Source of rendered markup to compare with.</param> /// <returns>Any differences found.</returns> public static IReadOnlyList <IDiff> CompareTo(this IRenderedFragment actual, IRenderedFragment expected) { if (actual is null) { throw new ArgumentNullException(nameof(actual)); } if (expected is null) { throw new ArgumentNullException(nameof(expected)); } return(actual.GetNodes().CompareTo(expected.GetNodes())); }
/// <summary> /// Verifies that the rendered markup from the <paramref name="actual"/> <see cref="IRenderedFragment"/> matches /// the <paramref name="expected"/> markup, using the <see cref="HtmlComparer"/> type. /// </summary> /// <exception cref="HtmlEqualException">Thrown when the <paramref name="actual"/> markup does not match the <paramref name="expected"/> markup.</exception> /// <param name="actual">The rendered fragment to verify.</param> /// <param name="expected">The expected markup.</param> /// <param name="userMessage">A custom user message to display in case the verification fails.</param> public static void MarkupMatches(this IRenderedFragment actual, string expected, string?userMessage = null) { if (actual is null) { throw new ArgumentNullException(nameof(actual)); } if (expected is null) { throw new ArgumentNullException(nameof(expected)); } var actualNodes = actual.GetNodes(); var expectedNodes = actual.TestContext.HtmlParser.Parse(expected); actualNodes.MarkupMatches(expectedNodes, userMessage); }
/// <summary> /// Compare the rendered markup in the <paramref name="actual"/> <see cref="IRenderedFragment"/> /// with that in the <paramref name="expected"/> markup string. /// </summary> /// <param name="actual">Source of rendered markup to check.</param> /// <param name="expected">Markup to compare with.</param> /// <returns>Any differences found.</returns> public static IReadOnlyList <IDiff> CompareTo(this IRenderedFragment actual, string expected) { if (actual is null) { throw new ArgumentNullException(nameof(actual)); } if (expected is null) { throw new ArgumentNullException(nameof(expected)); } var actualNodes = actual.GetNodes(); var expectedNodes = actual.TestContext.HtmlParser.Parse(expected); return(actualNodes.CompareTo(expectedNodes)); }