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
Copy file name to clipboardExpand all lines: MIGRATION.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,3 +33,9 @@ The `bunit.core` and `bunit.web` packages have been merged into a single `bunit`
33
33
34
34
### `WebTestRender` merged into `TestRender`
35
35
The `WebTestRender` class has been merged into the `TestRender` class. If you used `WebTestRender`, you should replace it with `TestRender`.
36
+
37
+
## Renamed `Fake` to `Bunit` in many test doubles
38
+
The `Fake` prefix has been replaced with `Bunit` in many test doubles. For example, `FakeNavigationManager` is now `BunitNavigationManager`. If you reference any of these types explicitly, you need to update your code.
39
+
40
+
### Renamed `AddTestAuthorization` to `AddAuthorization`
41
+
The `AddTestAuthorization` method on `TestContext` has been renamed to `AddAuthorization`. If you used `AddTestAuthorization`, you should replace it with `AddAuthorization`.
Copy file name to clipboardExpand all lines: docs/site/docs/providing-input/passing-parameters-to-components.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
@@ -469,7 +469,7 @@ When rendering a `RenderFragment` using the <xref:Bunit.TestContext.Render(Micro
469
469
## Passing query parameters (`SupplyParameterFromQuery`) to a component
470
470
In .NET 6 and later, components can receive parameters from a query string if the parameter is annotated with the `[SupplyParameterFromQuery]` attribute in addition to the `[Parameter]` attribute.
471
471
472
-
In .NET 8 however, the `[Parameter]` attribute is no longer required, which means a value cannot be passed to the component during testing using the normal methods, e.g. the <xref:Bunit.ComponentParameterCollectionBuilder`1>'s `Add` method, if a component parameter is only annotated with the `[SupplyParameterFromQuery]` attribute. Instead, pass a query string parameters by setting it using the <xref:Bunit.TestDoubles.FakeNavigationManager>.
472
+
In .NET 8 however, the `[Parameter]` attribute is no longer required, which means a value cannot be passed to the component during testing using the normal methods, e.g. the <xref:Bunit.ComponentParameterCollectionBuilder`1>'s `Add` method, if a component parameter is only annotated with the `[SupplyParameterFromQuery]` attribute. Instead, pass a query string parameters by setting it using the <xref:Bunit.TestDoubles.BunitNavigationManager>.
Copy file name to clipboardExpand all lines: docs/site/docs/test-doubles/auth.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
-
uid: faking-auth
3
-
title: Faking authentication and authorization
2
+
uid: bunit-auth
3
+
title: Adding authentication and authorization
4
4
---
5
5
6
-
# Faking authentication and authorization
6
+
# Adding authentication and authorization
7
7
8
8
bUnit comes with test-specific implementations of Blazor's authentication and authorization types, making it easy to test components that use Blazor's `<AuthorizeView>`, `<CascadingAuthenticationState>` and `<AuthorizeRouteView>` components, as well as the `AuthenticationStateProvider` type.
9
9
@@ -15,10 +15,10 @@ The test implementation of Blazor's authentication and authorization can be put
15
15
-**Authenticated** and **authorized**
16
16
-**Authenticated** and **authorized** with one or more **roles**, **claims**, and/or **policies**
17
17
18
-
bUnit's authentication and authorization implementation is easily available by calling [`AddTestAuthorization()`](xref:Bunit.TestDoubles.FakeAuthorizationExtensions.AddTestAuthorization(Bunit.TestContextBase)) on a test context. This adds the necessary services to the `Services` collection and the `CascadingAuthenticationState` component to the [root render tree](xref:root-render-tree). The method returns an instance of the <xref:Bunit.TestDoubles.TestAuthorizationContext> type that allows you to control the authentication and authorization state for a test.
18
+
bUnit's authentication and authorization implementation is easily available by calling [`AddAuthorization()`](xref:Bunit.TestDoubles.BunitAuthorizationExtensions.AddAuthorization(Bunit.TestContextBase)) on a test context. This adds the necessary services to the `Services` collection and the `CascadingAuthenticationState` component to the [root render tree](xref:root-render-tree). The method returns an instance of the <xref:Bunit.TestDoubles.TestAuthorizationContext> type that allows you to control the authentication and authorization state for a test.
19
19
20
20
> [!NOTE]
21
-
> If your test class inherits directly from bUnit's <xref:Bunit.TestContext> then you need to call the [`AddTestAuthorization()`](xref:Bunit.TestDoubles.FakeAuthorizationExtensions.AddTestAuthorization(Bunit.TestContextBase)) method on `this`, since `AddTestAuthorization()` is an extension method, otherwise it wont be available. E.g.: `this.AddTestAuthorization()`.
21
+
> If your test class inherits directly from bUnit's <xref:Bunit.TestContext> then you need to call the [`AddAuthorization()`](xref:Bunit.TestDoubles.BunitAuthorizationExtensions.AddAuthorization(Bunit.TestContextBase)) method on `this`, since `AddAuthorization()` is an extension method, otherwise it wont be available. E.g.: `this.AddAuthorization()`.
22
22
23
23
The following sections show how to set each of these states in a test.
24
24
@@ -36,33 +36,33 @@ To set the state to unauthenticated and unauthorized, do the following:
The highlighted line shows how `AddTestAuthorization()` is used to add the test-specific implementation of Blazor's authentication and authorization types to the `Services` collection, which makes the authentication state available to other services as well as components used throughout the test that require it.
39
+
The highlighted line shows how `AddAuthorization()` is used to add the test-specific implementation of Blazor's authentication and authorization types to the `Services` collection, which makes the authentication state available to other services as well as components used throughout the test that require it.
40
40
41
-
After calling `AddTestAuthorization()`, the default authentication state is unauthenticated and unauthorized.
41
+
After calling `AddAuthorization()`, the default authentication state is unauthenticated and unauthorized.
42
42
43
43
### Authenticating and authorizing state
44
44
45
45
To set the state to authenticating and authorizing, do the following:
After calling `AddTestAuthorization()`, the returned <xref:Bunit.TestDoubles.TestAuthorizationContext> is used to set the authenticating and authorizing state through the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthorizing> method.
49
+
After calling `AddAuthorization()`, the returned <xref:Bunit.TestDoubles.TestAuthorizationContext> is used to set the authenticating and authorizing state through the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthorizing> method.
50
50
51
51
### Authenticated and unauthorized state
52
52
53
53
To set the state to authenticated and unauthorized, do the following:
After calling `AddTestAuthorization()`, the returned <xref:Bunit.TestDoubles.TestAuthorizationContext> is used to set the authenticated and unauthorized state through the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthorized(System.String,Bunit.TestDoubles.AuthorizationState)> method.
57
+
After calling `AddAuthorization()`, the returned <xref:Bunit.TestDoubles.TestAuthorizationContext> is used to set the authenticated and unauthorized state through the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthorized(System.String,Bunit.TestDoubles.AuthorizationState)> method.
58
58
59
59
### Authenticated and authorized state
60
60
61
61
To set the state to authenticated and authorized, do the following:
After calling `AddTestAuthorization()`, the returned <xref:Bunit.TestDoubles.TestAuthorizationContext> is used to set the authenticated and authorized state through the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthorized(System.String,Bunit.TestDoubles.AuthorizationState)> method.
65
+
After calling `AddAuthorization()`, the returned <xref:Bunit.TestDoubles.TestAuthorizationContext> is used to set the authenticated and authorized state through the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthorized(System.String,Bunit.TestDoubles.AuthorizationState)> method.
66
66
67
67
Note that the second parameter, `AuthorizationState`, is optional, and defaults to `AuthorizationState.Authorized` if not specified.
Copy file name to clipboardExpand all lines: docs/site/docs/test-doubles/fake-webassemblyhostenvironment.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
---
2
-
uid: fake-webassemblyhostenvironment
3
-
title: Faking IWebAssemblyHostEnvironment
2
+
uid: bunit-webassemblyhostenvironment
3
+
title: Adding IWebAssemblyHostEnvironment
4
4
---
5
5
6
-
# Faking`IWebAssemblyHostEnvironment`
6
+
# Adding`IWebAssemblyHostEnvironment`
7
7
8
-
bUnit has a fake implementation of Blazor's `IWebAssemblyHostEnvironment` built-in, which is added by default to bUnit's `TestContext.Services` service provider. That means nothing special is needed to test components that depend on `IWebAssemblyHostEnvironment`, as it is already available by default.
8
+
bUnit has itws own implementation of Blazor's `IWebAssemblyHostEnvironment` built-in, which is added by default to bUnit's `TestContext.Services` service provider. That means nothing special is needed to test components that depend on `IWebAssemblyHostEnvironment`, as it is already available by default.
9
9
10
-
Out of the box, the fake implementation has its `Environment` property set to `production`, and its `BaseAddress` set to `/`.
10
+
Out of the box, the implementation has its `Environment` property set to `production`, and its `BaseAddress` set to `/`.
11
11
12
12
## Setting `Environment` and `BaseAddress`
13
13
14
-
Lets look at a few examples of how to set the two `IWebAssemblyHostEnvironment` properties `Environment` and `BaseAddress` via the built-in fake.
14
+
Lets look at a few examples of how to set the two `IWebAssemblyHostEnvironment` properties `Environment` and `BaseAddress` via the built-in object.
15
15
16
16
In the examples, we'll use the following `<HelloWorld>` component:
17
17
@@ -30,7 +30,7 @@ To verify that the `<HelloWorld>` component correctly says hello to the develope
Copy file name to clipboardExpand all lines: docs/site/docs/test-doubles/navigation-manager.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
-
uid: fake-navigation-manager
3
-
title: Faking NavigationManager
2
+
uid: bunit-navigation-manager
3
+
title: Adding NavigationManager
4
4
---
5
5
6
-
# Faking`NavigationManager`
6
+
# Adding`NavigationManager`
7
7
8
-
bUnit has a fake version of Blazor's `NavigationManager` built-in, which is added by default to bUnit's `TestContext.Services` service provider. That means nothing special is needed to test components that depend on `NavigationManager`, as it is already available by default.
8
+
bUnit has its own version of Blazor's `NavigationManager` built-in, which is added by default to bUnit's `TestContext.Services` service provider. That means nothing special is needed to test components that depend on `NavigationManager`, as it is already available by default.
9
9
10
10
## Verify `NavigationManager` interactions
11
11
@@ -43,7 +43,7 @@ To verify that the `<PrintCurrentUrl>` component correctly listens to location c
If a component issues multiple `NavigateTo` calls, then it is possible to inspect the navigation history by accessing the <xref:Bunit.TestDoubles.FakeNavigationManager.History> property. It's a stack based structure, meaning the latest navigations will be first in the collection at index 0.
71
+
If a component issues multiple `NavigateTo` calls, then it is possible to inspect the navigation history by accessing the <xref:Bunit.TestDoubles.BunitNavigationManager.History> property. It's a stack based structure, meaning the latest navigations will be first in the collection at index 0.
72
72
73
73
## Asserting that navigation was prevented with the `NavigationLock` component
74
74
@@ -93,7 +93,7 @@ A component can look like this:
93
93
A typical test, which asserts that the navigation got prevented, would look like this:
0 commit comments