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
@@ -49,7 +49,7 @@ The other parameters affect how the test runs, and how it is displayed in e.g. V
49
49
50
50
The <xref:Bunit.Fixture> component only accepts the <xref:Bunit.ComponentUnderTest> and <xref:Bunit.Fragment> components as its child content. All other components and markup are ignored. E.g.:
Here are the rules for the <xref:Bunit.Fixture> components child content:
55
55
@@ -87,7 +87,7 @@ The generic versions of <xref:Bunit.Fixture.GetComponentUnderTest``1> and <xref:
87
87
88
88
Let's look at a complete example, where we have a simple task list component, `<SimpleTodo>`, listed below, that have a service injected, receive a cascading value, and changes between renders:
Copy file name to clipboardExpand all lines: docs/site/docs/getting-started/writing-razor-tests.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ A test for a Blazor component can be written in a Blazor component, using a mix
19
19
20
20
Razor tests are written in Blazor test components. To make our life's a little easier, let us first set up a `_Imports.razor` file, with the using statements we are going to be using throughout our tests. Simply add the following `_Imports.razor` to the root folder where you will be placing your Blazor test components:
Copy file name to clipboardExpand all lines: docs/site/docs/interaction/awaiting-async-state.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The [`WaitForState(Func<Boolean>, TimeSpan?)`](xref:Bunit.RenderedFragmentWaitFo
20
20
21
21
Let us look at an example. Consider the following `<AsyncData>` component, who awaits an async `TextService` in its `OnInitializedAsync()` life-cycle method. When the service returns the data, the component will automatically re-render, to update its rendered markup.
Copy file name to clipboardExpand all lines: docs/site/docs/providing-input/inject-services-into-components.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ In bUnit, you register the services in the `Services` collection _before_ you re
13
13
14
14
The following sections shows how to do this in C# and Razor based tests. The examples will test the `<WeatherForecasts>` component listed below, that depends on the `IWeatherForecastService` service, injected in line 1:
@@ -30,15 +30,15 @@ The highlighted line shows how the `IWeatherForecastService` is registered in th
30
30
31
31
Here is a Razor based test that registers the `IWeatherForecastService` in the `Services` collection during the `Setup` methods, which is needed by the `<WeatherForecasts>` component listed above.
The highlighted line shows how the `IWeatherForecastService` is registered, using the standard .NET Core DI services method, [`AddSingleton`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicecollectionserviceextensions.addsingleton?view=dotnet-plat-ext-3.1#Microsoft_Extensions_DependencyInjection_ServiceCollectionServiceExtensions_AddSingleton__1_Microsoft_Extensions_DependencyInjection_IServiceCollection___0_).
36
36
37
37
This can either be done via the `Fixture`'s `Setup` method as in this example, if you want to separate the service registration from the test method, or it can be done in the test method _before_ calling `GetComponentUnderTest()`.
38
38
39
39
In the following example shows how to do this with `<SnapshotTest>` tests:
ThisisjustregularBlazorchildcontentparameterpassing, e.g. aschildcontenttothecomponentundertest, whichisthesameforboth `Fixture` and `SnapshotTest` razortests.
128
128
@@ -143,7 +143,7 @@ These examples do the same thing, here is what is going on:
ThisisjustregularBlazorcascadingvalueparameterpassing, whichisthesameforboth `Fixture` and `SnapshotTest` razortests. Inthiscase, the `<CascadingValue>` componentisusedtopasstheunnamedparametervalue.
387
387
@@ -402,7 +402,7 @@ These examples do the same thing, i.e. pass in value `Egil Hansen` to the cascad
ThisisjustregularBlazorcascadingvalueparameterpassing, whichisthesameforboth `Fixture` and `SnapshotTest` razortests. Inthiscase, the `<CascadingValue>` componentisusedtopassanamedparametervalue, sinceboththe `Name` and `Value` parametersarespecified.
408
408
@@ -424,7 +424,7 @@ These examples do the same thing, i.e. pass both the unnamed `IsDarkTheme` casca
ThisisjustregularBlazorchildcontentparameterpassing, whereonecomponentisrenderedinsideanother, i.e. the `<HelloWorld>` componentinsidethe `<Wrapper>` component.
Copy file name to clipboardExpand all lines: docs/site/docs/verification/async-assertion.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The [`WaitForAssertion(Action, TimeSpan?)`](xref:Bunit.RenderedFragmentWaitForHe
20
20
21
21
Let us look at an example. Consider the following `<AsyncData>` component, who awaits an async `TextService` in its `OnInitializedAsync()` life-cycle method. When the service returns the data, the component will automatically re-render, to update its rendered markup.
0 commit comments