Skip to content

Commit 3ad4fa1

Browse files
linkdotnetbUnitBot
authored andcommitted
fix: Fixes after merge
1 parent 04576c1 commit 3ad4fa1

13 files changed

+46
-46
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ List of new features.
664664

665665
- Added `Render(RenderFragment)` and `Render<TComponent>(RenderFragment)` methods to `TestContext`, as well as various overloads to the `MarkupMatches` methods, that also takes a `RenderFragment` as the expected value.
666666

667-
The difference between the generic `Render` method and the non-generic one is that the generic returns an `IRenderedComponent<TComponent>`, whereas the non-generic one returns a `IRenderedFragment`.
667+
The difference between the generic `Render` method and the non-generic one is that the generic returns an `IRenderedComponent<TComponent>`, whereas the non-generic one returns a `RenderedFragment`.
668668

669669
Calling `Render<TComponent>(RenderFragent)` is equivalent to calling `Render(RenderFragment).FindComponent<TComponent>()`, e.g. it returns the first component in the render tree of type `TComponent`. This is different from the `RenderComponent<TComponent>()` method, where `TComponent` _is_ the root component of the render tree.
670670

MIGRATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document describes the changes that need to be made to migrate from bUnit 1
44
## Removal of `GetChangesSinceFirstRender` and `GetChangesSinceLastRender` methods
55
The `GetChangesSinceFirstRender` and `GetChangesSinceLastRender` methods have been removed from `RenderedComponent<TComponent>`. There is no one-to-one replacement for these methods, but the general idea is to select the HTML in question via `Find` and assert against that.
66

7-
Alternatively, the `IRenderedFragment` still offers the `OnMarkupUpdated` event, which can be used to assert against the markup after a render.
7+
Alternatively, the `RenderedFragment` still offers the `OnMarkupUpdated` event, which can be used to assert against the markup after a render.
88

99
## Removal of `IsNullOrEmpty` extension method on `IEnumerable<T>` and `CreateLogger` on `IServiceProvider`
1010
The `IsNullOrEmpty` extension method on `IEnumerable<T>` has been removed, as well as the `CreateLogger` extension method on `IServiceProvider`. These extension methods are pretty common and conflict with other libraries. These methods can be recreated like this:
@@ -29,7 +29,7 @@ The `bunit.core` and `bunit.web` packages have been merged into a single `bunit`
2929
## Removal of unneeded abstraction
3030

3131
### `IRenderedComponentBase<TComponent>` and `RenderedFragmentBase`
32-
`IRenderedComponentBase<TComponent>`, `IRenderedComponent<TComponent>`, `IRenderedFragmentBase`, `IRenderedFragment` and `RenderedFragmentBase` have been removed.
32+
`IRenderedComponentBase<TComponent>`, `IRenderedComponent<TComponent>`, `RenderedFragmentBase`, `RenderedFragment` and `RenderedFragmentBase` have been removed.
3333
If you used either of these types, you should replace them with `RenderedComponent<TComponent>` or `RenderedFragment` respectively.
3434

3535
### `WebTestRender` merged into `BunitTestRender`

docs/site/docs/verification/verify-markup.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ The following sections will cover each of these.
2222

2323
## Result of rendering components
2424

25-
When a component is rendered in a test, the result is a <xref:Bunit.IRenderedFragment> or a <xref:Bunit.IRenderedComponent`1>. Through these, it is possible to access the rendered markup (HTML) of the component and, in the case of <xref:Bunit.IRenderedComponent`1>, the instance of the component.
25+
When a component is rendered in a test, the result is a <xref:Bunit.RenderedFragment> or a <xref:Bunit.RenderedComponent`1>. Through these, it is possible to access the rendered markup (HTML) of the component and, in the case of <xref:Bunit.RenderedComponent`1>, the instance of the component.
2626

2727
> [!NOTE]
2828
> An <xref:Bunit.RenderedComponent`1> inherits from <xref:Bunit.RenderedFragment>. This page will only cover features of the <xref:Bunit.RenderedFragment> type. <xref:Bunit.RenderedComponent`1> is covered on the <xref:verify-component-state> page.
2929
3030
## Inspecting DOM nodes
3131

32-
The rendered markup from a component is available as a DOM node through the <xref:Bunit.IRenderedFragment.Nodes> property on <xref:Bunit.IRenderedFragment>. The nodes and element types comes from [AngleSharp](https://anglesharp.github.io/) that follows the W3C DOM API specifications and gives you the same results as a state-of-the-art browser’s implementation of the DOM API in JavaScript. Besides the official DOM API, AngleSharp and bUnit add some useful extension methods on top. This makes working with DOM nodes convenient.
32+
The rendered markup from a component is available as a DOM node through the <xref:Bunit.RenderedFragment.Nodes> property on <xref:Bunit.RenderedFragment>. The nodes and element types comes from [AngleSharp](https://anglesharp.github.io/) that follows the W3C DOM API specifications and gives you the same results as a state-of-the-art browser’s implementation of the DOM API in JavaScript. Besides the official DOM API, AngleSharp and bUnit add some useful extension methods on top. This makes working with DOM nodes convenient.
3333

3434
### Finding DOM elements
3535

3636
bUnit supports multiple different ways of searching and querying the rendered HTML elements:
3737

3838
- `FindByLabelText(string labelText)` that takes a text string used to label an input element and returns an `IElement` as output, or throws an exception if none are found (this is included in the experimental library [bunit.web.query](https://www.nuget.org/packages/bunit.web.query)). Use this method when possible compared to the generic `Find` and `FindAll` methods.
39-
- [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.IRenderedFragment,System.String)) takes a "CSS selector" as input and returns an `IElement` as output, or throws an exception if none are found.
40-
- [`FindAll(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.FindAll(Bunit.IRenderedFragment,System.String,System.Boolean)) takes a "CSS selector" as input and returns a list of `IElement` elements.
39+
- [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.RenderedFragment,System.String)) takes a "CSS selector" as input and returns an `IElement` as output, or throws an exception if none are found.
40+
- [`FindAll(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.FindAll(Bunit.RenderedFragment,System.String,System.Boolean)) takes a "CSS selector" as input and returns a list of `IElement` elements.
4141

42-
Let's see some examples of using the [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.IRenderedFragment,System.String)) and [`FindAll(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.FindAll(Bunit.IRenderedFragment,System.String,System.Boolean)) methods to query the `<FancyTable>` component listed below.
42+
Let's see some examples of using the [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.RenderedFragment,System.String)) and [`FindAll(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.FindAll(Bunit.RenderedFragment,System.String,System.Boolean)) methods to query the `<FancyTable>` component listed below.
4343

4444
[!code-razor[FancyTable.razor](../../../samples/components/FancyTable.razor)]
4545

@@ -53,15 +53,15 @@ Once you have one or more elements, you verify against them, such as by inspec
5353

5454
#### Auto-refreshing Find() queries
5555

56-
An element found with the [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.IRenderedFragment,System.String)) method will be updated if the component it came from is re-rendered.
56+
An element found with the [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.RenderedFragment,System.String)) method will be updated if the component it came from is re-rendered.
5757

58-
However, that does not apply to elements that are found by traversing the DOM tree via the <xref:Bunit.IRenderedFragment.Nodes> property on <xref:Bunit.IRenderedFragment>, for example, as those nodes do not know when their root component is re-rendered. Consequently, they don’t know when they should be updated.
58+
However, that does not apply to elements that are found by traversing the DOM tree via the <xref:Bunit.RenderedFragment.Nodes> property on <xref:Bunit.RenderedFragment>, for example, as those nodes do not know when their root component is re-rendered. Consequently, they don’t know when they should be updated.
5959

60-
As a result of this, it is always recommended to use the [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.IRenderedFragment,System.String)) method when searching for a single element. Alternatively, always reissue the query whenever you need the element.
60+
As a result of this, it is always recommended to use the [`Find(string cssSelector)`](xref:Bunit.RenderedFragmentExtensions.Find(Bunit.RenderedFragment,System.String)) method when searching for a single element. Alternatively, always reissue the query whenever you need the element.
6161

6262
#### Auto-refreshable FindAll() queries
6363

64-
The [`FindAll(string cssSelector, bool enableAutoRefresh = false)`](xref:Bunit.RenderedFragmentExtensions.FindAll(Bunit.IRenderedFragment,System.String,System.Boolean)) method has an optional parameter, `enableAutoRefresh`, which when set to `true` will return a collection of `IElement`. This automatically refreshes itself when the component the elements came from is re-rendered.
64+
The [`FindAll(string cssSelector, bool enableAutoRefresh = false)`](xref:Bunit.RenderedFragmentExtensions.FindAll(Bunit.RenderedFragment,System.String,System.Boolean)) method has an optional parameter, `enableAutoRefresh`, which when set to `true` will return a collection of `IElement`. This automatically refreshes itself when the component the elements came from is re-rendered.
6565

6666
## Semantic comparison of markup
6767

@@ -122,7 +122,7 @@ Learn more about the customization options on the <xref:semantic-html-comparison
122122

123123
## Verification of raw markup
124124

125-
To access the rendered markup of a component, just use the <xref:Bunit.IRenderedFragment.Markup> property on <xref:Bunit.IRenderedFragment>. This holds the *raw* HTML from the component as a `string`.
125+
To access the rendered markup of a component, just use the <xref:Bunit.RenderedFragment.Markup> property on <xref:Bunit.RenderedFragment>. This holds the *raw* HTML from the component as a `string`.
126126

127127
> [!WARNING]
128128
> Be aware that all indentions and whitespace in your components (`.razor` files) are included in the raw rendered markup, so it is often wise to normalize the markup string a little. For example, via the string `Trim()` method to make the tests more stable. Otherwise, a change to the formatting in your components might break the tests unnecessarily when it does not need to.

src/bunit.generators.internal/Web.AngleSharp/WrapperElementGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static void GenerateOrdinaryMethod(StringBuilder source, IMethodSymbol m
6464
var methodParts = method.ToDisplayParts(GeneratorConfig.SymbolFormat);
6565

6666
// It seems that the ToDisplayParts will return ...
67-
//
67+
//
6868
// public global::AngleSharp.Dom.IShadowRoot AttachShadow(global::AngleSharp.Dom.ShadowRootMode mode = 0)
6969
//
7070
// when called on a method with a default enum parameters specified.

src/bunit.web.query/ByLabelTextElementFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace Bunit;
55

66
internal sealed class ByLabelTextElementFactory : IElementWrapperFactory
77
{
8-
private readonly IRenderedFragment testTarget;
8+
private readonly RenderedFragment testTarget;
99
private readonly string labelText;
1010
private readonly ByLabelTextOptions options;
1111

1212
public Action? OnElementReplaced { get; set; }
1313

14-
public ByLabelTextElementFactory(IRenderedFragment testTarget, string labelText, ByLabelTextOptions options)
14+
public ByLabelTextElementFactory(RenderedFragment testTarget, string labelText, ByLabelTextOptions options)
1515
{
1616
this.testTarget = testTarget;
1717
this.labelText = labelText;

src/bunit.web.query/Labels/LabelQueryExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Bunit;
55

66
/// <summary>
7-
/// Extension methods for querying IRenderedFragments by Label
7+
/// Extension methods for querying RenderedFragments by Label
88
/// </summary>
99
public static class LabelQueryExtensions
1010
{
@@ -23,7 +23,7 @@ public static class LabelQueryExtensions
2323
/// <param name="renderedFragment">The rendered fragment to search.</param>
2424
/// <param name="labelText">The text of the label to search (i.e. the InnerText of the Label, such as "First Name" for a `<label>First Name</label>`)</param>
2525
/// <param name="configureOptions">Method used to override the default behavior of FindByLabelText.</param>
26-
public static IElement FindByLabelText(this IRenderedFragment renderedFragment, string labelText, Action<ByLabelTextOptions>? configureOptions = null)
26+
public static IElement FindByLabelText(this RenderedFragment renderedFragment, string labelText, Action<ByLabelTextOptions>? configureOptions = null)
2727
{
2828
var options = ByLabelTextOptions.Default;
2929
if (configureOptions is not null)
@@ -35,7 +35,7 @@ public static IElement FindByLabelText(this IRenderedFragment renderedFragment,
3535
return FindByLabelTextInternal(renderedFragment, labelText, options) ?? throw new LabelNotFoundException(labelText);
3636
}
3737

38-
internal static IElement? FindByLabelTextInternal(this IRenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
38+
internal static IElement? FindByLabelTextInternal(this RenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
3939
{
4040
foreach (var strategy in LabelTextQueryStrategies)
4141
{

src/bunit.web.query/Labels/Strategies/ILabelTextQueryStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ namespace Bunit.Labels.Strategies;
44

55
internal interface ILabelTextQueryStrategy
66
{
7-
IElement? FindElement(IRenderedFragment renderedFragment, string labelText, ByLabelTextOptions options);
7+
IElement? FindElement(RenderedFragment renderedFragment, string labelText, ByLabelTextOptions options);
88
}

src/bunit.web.query/Labels/Strategies/LabelTextUsingAriaLabelStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Bunit.Labels.Strategies;
55

66
internal sealed class LabelTextUsingAriaLabelStrategy : ILabelTextQueryStrategy
77
{
8-
public IElement? FindElement(IRenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
8+
public IElement? FindElement(RenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
99
{
1010
var caseSensitivityQualifier = options.ComparisonType switch
1111
{

src/bunit.web.query/Labels/Strategies/LabelTextUsingAriaLabelledByStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Bunit.Labels.Strategies;
55

66
internal sealed class LabelTextUsingAriaLabelledByStrategy : ILabelTextQueryStrategy
77
{
8-
public IElement? FindElement(IRenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
8+
public IElement? FindElement(RenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
99
{
1010
var elementsWithAriaLabelledBy = renderedFragment.Nodes.TryQuerySelectorAll("[aria-labelledby]");
1111

src/bunit.web.query/Labels/Strategies/LabelTextUsingForAttributeStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Bunit.Labels.Strategies;
55

66
internal sealed class LabelTextUsingForAttributeStrategy : ILabelTextQueryStrategy
77
{
8-
public IElement? FindElement(IRenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
8+
public IElement? FindElement(RenderedFragment renderedFragment, string labelText, ByLabelTextOptions options)
99
{
1010
var matchingLabel = renderedFragment.Nodes.TryQuerySelectorAll("label")
1111
.SingleOrDefault(l => l.TextContent.Trim().Equals(labelText, options.ComparisonType));

0 commit comments

Comments
 (0)