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
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@ This document describes the changes that need to be made to migrate from bUnit 1
4
4
## Removal of `GetChangesSinceFirstRender` and `GetChangesSinceLastRender` methods
5
5
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.
6
6
7
-
Alternatively, the `IRenderFragment` still offers the `OnMarkupUpdated` event, which can be used to assert against the markup after a render.
7
+
Alternatively, the `IRenderedFragment` still offers the `OnMarkupUpdated` event, which can be used to assert against the markup after a render.
8
8
9
-
## Removal of `IsNullOrEmpty` extension method on `IEnumerable<T>` and `CreateLogger` on `IserviceProvider`
9
+
## Removal of `IsNullOrEmpty` extension method on `IEnumerable<T>` and `CreateLogger` on `IServiceProvider`
10
10
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:
11
11
12
12
```csharp
@@ -29,10 +29,11 @@ The `bunit.core` and `bunit.web` packages have been merged into a single `bunit`
29
29
## Removal of unneeded abstraction
30
30
31
31
### `IRenderedComponentBase<TComponent>` and `RenderedFragmentBase`
32
-
`IRenderedComponentBase<TComponent>` and `RenderedFragmentBase` have been removed. They were used to provide a common base class for `RenderedComponent<TComponent>` and `RenderedFragment`, but this is no longer needed (due to the merge of the project). If you used either of these interfaces, you should replace them with `RenderedComponent<TComponent>` and `RenderedFragment` respectively.
32
+
`IRenderedComponentBase<TComponent>`, `IRenderedComponent<TComponent>`, `IRenderedFragmentBase`, `IRenderedFragment` and `RenderedFragmentBase` have been removed.
33
+
If you used either of these types, you should replace them with `RenderedComponent<TComponent>` or `RenderedFragment` respectively.
33
34
34
-
### `WebTestRender` merged into `TestRender`
35
-
The `WebTestRender` class has been merged into the `TestRender` class. If you used `WebTestRender`, you should replace it with `TestRender`.
35
+
### `WebTestRender` merged into `BunitTestRender`
36
+
The `WebTestRender` class has been merged into the `TestRender` class. If you used `WebTestRender`, you should replace it with `BunitTestRender`.
36
37
37
38
## Renamed `Fake` to `Bunit` in many test doubles
38
39
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.
Copy file name to clipboardExpand all lines: docs/site/docs/test-doubles/auth.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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 [`AddAuthorization()`](xref:Bunit.TestDoubles.BunitAuthorizationExtensions.AddAuthorization(Bunit.TestContext)) 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.TestContext.AddAuthorization(Bunit.TestContext)) 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.BunitAuthorizationContext> 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 [`AddAuthorization()`](xref:Bunit.TestDoubles.BunitAuthorizationExtensions.AddAuthorization(Bunit.TestContext)) method on `this`, since `AddAuthorization()` is an extension method, otherwise it wont be available. E.g.: `this.AddAuthorization()`.
21
+
> If your test class inherits directly from bUnit's <xref:Bunit.TestContext> then you need to call the [`AddAuthorization()`](xref:Bunit.TestContext.AddAuthorization(Bunit.TestContext)) method on `this`, since `AddAuthorization()` is an extension method, otherwise it wont be available. E.g.: `AddAuthorization()`.
22
22
23
23
The following sections show how to set each of these states in a test.
24
24
@@ -46,23 +46,23 @@ To set the state to authenticating and authorizing, do the following:
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.
49
+
After calling `AddAuthorization()`, the returned <xref:Bunit.TestDoubles.BunitAuthorizationContext> is used to set the authenticating and authorizing state through the <xref:Bunit.TestDoubles.BunitAuthorizationContext.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 `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.
57
+
After calling `AddAuthorization()`, the returned <xref:Bunit.TestDoubles.BunitAuthorizationContext> is used to set the authenticated and unauthorized state through the <xref:Bunit.TestDoubles.BunitAuthorizationContext.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 `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.
65
+
After calling `AddAuthorization()`, the returned <xref:Bunit.TestDoubles.BunitAuthorizationContext> is used to set the authenticated and authorized state through the <xref:Bunit.TestDoubles.BunitAuthorizationContext.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.
68
68
@@ -80,7 +80,7 @@ To specify one or more roles for the authenticated and authorized user, do the f
The highlighted line shows how the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetRoles(System.String[])> method is used to specify a single role. To specify multiple roles, do the following:
83
+
The highlighted line shows how the <xref:Bunit.TestDoubles.BunitAuthorizationContext.SetRoles(System.String[])> method is used to specify a single role. To specify multiple roles, do the following:
The highlighted line shows how the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetPolicies(System.String[])> method is used to specify one policy. To specify multiple policies, do the following:
93
+
The highlighted line shows how the <xref:Bunit.TestDoubles.BunitAuthorizationContext.SetPolicies(System.String[])> method is used to specify one policy. To specify multiple policies, do the following:
The highlighted line shows how the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetClaims(System.Security.Claims.Claim[])> method is used to pass two instances of the `Claim` type.
103
+
The highlighted line shows how the <xref:Bunit.TestDoubles.BunitAuthorizationContext.SetClaims(System.Security.Claims.Claim[])> method is used to pass two instances of the `Claim` type.
104
104
105
105
### Example of passing both roles, claims, and policies
106
106
@@ -116,4 +116,4 @@ To specify a authentication type for the authenticated and authorized user, do t
The highlighted line shows how the <xref:Bunit.TestDoubles.TestAuthorizationContext.SetAuthenticationType(System.String)> method is used to change the `Identity.AuthenticationType` of the user.
119
+
The highlighted line shows how the <xref:Bunit.TestDoubles.BunitAuthorizationContext.SetAuthenticationType(System.String)> method is used to change the `Identity.AuthenticationType` of the user.
0 commit comments