You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added MarkupMatches(this string actual ...) extension methods. Make it easier to compare just the text content from a DON text node with a string, while still getting the benefit of the semantic HTML comparer.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-38Lines changed: 3 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,50 +9,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
9
9
### Added
10
10
List of new features.
11
11
12
-
- Authorization fakes added to make it much easier to test components that use authentication and authorization. By [@DarthPedro](https://github.com/DarthPedro) in [#151](https://github.com/egil/bUnit/pull/151).
12
+
- Authorization fakes added to make it much easier to test components that use authentication and authorization. Learn more in the [Faking Blazor's Authentication and Authorization](https://bunit.egilhansen.com/docs/test-doubles/faking-auth) page. By [@DarthPedro](https://github.com/DarthPedro) in [#151](https://github.com/egil/bUnit/pull/151).
13
13
14
-
#### Authorization Fakes
15
-
Added authentication/authorization fake services to make it easy to test Blazor components that use authorization either through code or the AuthorizeView component.
16
-
You just need to call the AddTestAuthorization method on your TestContext.Services collection.
17
-
18
-
First define your component that uses AuthorizeView to render differently based on the user's authorization state:
- Added `MarkupMatches(this string actual ...)` extension methods. Make it easier to compare just the text content from a DON text node with a string, while still getting the benefit of the semantic HTML comparer.
50
15
51
16
### Changed
52
17
List of changes in existing functionality.
53
18
54
19
-`TestContextBase.Dispose` made virtual to allow inheritor's to override it. By [@SimonCropp](https://github.com/SimonCropp) in [#137](https://github.com/egil/bunit/pull/137).
55
-
- Changed naming convention for JSMock feature. All classes and methods containing `Js` (meaning JavaScript) renamed to `JS`. By [yourilima](https://github.com/yourilima) in [#150](https://github.com/egil/bUnit/pull/150)
20
+
-**[Breaking change]**Changed naming convention for JSMock feature and moved to new namespace, `Bunit.TestDoubles.JSInterop`. All classes and methods containing `Js` (meaning JavaScript) renamed to `JS` for consistency with Blazor's `IJSRuntime`. By [@yourilima](https://github.com/yourilima) in [#150](https://github.com/egil/bUnit/pull/150)
Copy file name to clipboardExpand all lines: docs/site/docs/verification/verify-markup.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,11 +83,9 @@ Here we use the `Find(string cssSelector)` method to find the `<small>` element,
83
83
> [!TIP]
84
84
> Working with `Find()`, `FindAll()`, `INode` and `INodeList` is covered later on this page.
85
85
86
-
<!-- TODO UNCOMMENT WHEN MarkupMatches(this string markup ... ) IS DONE
87
86
Text content can also be verified with the `MarkupMatches()` method, e.g. the text inside the `<small>` element. It has the advantage over regular string comparison that it removes insignificant whitespace in the text automatically, even between words, where a normal string `Trim()` method isn't enough. For example:
The semantic HTML comparer can be customized to make a test case even more stable and easier to maintain. It is e.g. possible to ignore an element or attribute during comparison, or provide an regular expression to the comparer when comparing a specific element or attribute, to make the comparer work with generated data.
Copy file name to clipboardExpand all lines: src/bunit.web/Asserting/MarkupMatchesAssertExtensions.cs
+84-25Lines changed: 84 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,72 @@ namespace Bunit
13
13
/// </summary>
14
14
publicstaticclassMarkupMatchesAssertExtensions
15
15
{
16
+
/// <summary>
17
+
/// Verifies that the rendered markup from the <paramref name="actual"/> markup fragment matches
18
+
/// the <paramref name="expected"/> markup fragment, using the <see cref="HtmlComparer"/> type.
19
+
/// </summary>
20
+
/// <exception cref="HtmlEqualException">Thrown when the <paramref name="actual"/> markup does not match the <paramref name="expected"/> markup.</exception>
21
+
/// <param name="actual">The markup fragment to verify.</param>
/// Verifies that the rendered markup from the <paramref name="actual"/> markup fragment matches
34
+
/// the <paramref name="expected"/> <see cref="IRenderedFragmentBase"/>, using the <see cref="HtmlComparer"/> type.
35
+
/// </summary>
36
+
/// <exception cref="HtmlEqualException">Thrown when the <paramref name="actual"/> markup does not match the <paramref name="expected"/> markup.</exception>
37
+
/// <param name="actual">The markup fragment to verify.</param>
/// Verifies that the rendered markup from the <paramref name="actual"/> markup fragment matches
51
+
/// the <paramref name="expected"/> <see cref="INodeList"/>, using the <see cref="HtmlComparer"/> type.
52
+
/// </summary>
53
+
/// <exception cref="HtmlEqualException">Thrown when the <paramref name="actual"/> markup does not match the <paramref name="expected"/> markup.</exception>
54
+
/// <param name="actual">The markup fragment to verify.</param>
/// Verifies that the rendered markup from the <paramref name="actual"/> markup fragment matches
68
+
/// the <paramref name="expected"/> <see cref="INode"/>, using the <see cref="HtmlComparer"/> type.
69
+
/// </summary>
70
+
/// <exception cref="HtmlEqualException">Thrown when the <paramref name="actual"/> markup does not match the <paramref name="expected"/> markup.</exception>
71
+
/// <param name="actual">The markup fragment to verify.</param>
0 commit comments