Skip to content

Commit fc0a252

Browse files
committed
fix: Drop obsolete/deprecated objects
Fixes #1887
1 parent 5a33823 commit fc0a252

12 files changed

Lines changed: 15 additions & 128 deletions

File tree

docs/site/docs/interaction/render-modes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void StaticRendering()
7575
# [Razor test code](#tab/razor)
7676

7777
```razor
78-
@inherits TestContext
78+
@inherits BunitContext
7979
@code {
8080
[Fact]
8181
public void InteractiveServer()
@@ -108,7 +108,7 @@ public void StaticRendering()
108108
***
109109

110110
## Setting the `RendererInfo` during testing
111-
To control the `ComponentBase.RendererInfo` property during testing, use the <xref:Bunit.BunitContext.SetRendererInfo(Microsoft.AspNetCore.Components.RendererInfo)> method on the `TestContext` class. The `SetRendererInfo` method takes an nullable `RendererInfo` object as a parameter. Passing `null` will set the `ComponentBase.RendererInfo` to `null`.
111+
To control the `ComponentBase.RendererInfo` property during testing, use the <xref:Bunit.BunitContext.SetRendererInfo(Microsoft.AspNetCore.Components.RendererInfo)> method on the `BunitContext` class. The `SetRendererInfo` method takes an nullable `RendererInfo` object as a parameter. Passing `null` will set the `ComponentBase.RendererInfo` to `null`.
112112

113113
A component (`AssistentComponent.razor`) might check if interactivity is given to enable a button:
114114

@@ -154,4 +154,4 @@ public void SimulatingInteractiveServerRendering()
154154
```
155155

156156
> [!NOTE]
157-
> If a component under test uses the `ComponentBase.RendererInfo` property and the `SetRendererInfo` on `TestContext` hasn't been passed in a `RendererInfo` object, the renderer will throw an exception.
157+
> If a component under test uses the `ComponentBase.RendererInfo` property and the `SetRendererInfo` on `BunitContext` hasn't been passed in a `RendererInfo` object, the renderer will throw an exception.

docs/site/docs/migrations/2to3.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ To migrate, update your test project's `<TargetFramework>` (or `<TargetFramework
1515
```diff
1616
- <TargetFramework>net8.0</TargetFramework>
1717
+ <TargetFramework>net10.0</TargetFramework>
18-
```
18+
```
19+
20+
## Removed obsolete and deprecated APIs
21+
22+
bUnit 3.x removes APIs that were kept around for backwards compatibility with bUnit 1.x and were marked `[Obsolete]` or scheduled for removal:
23+
24+
- `TestContext` class: use `BunitContext` instead.
25+
- `RenderComponent<TComponent>()` and `RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)`: use `Render<TComponent>()` instead.
26+
- `BunitSignOutSessionStateManager`: this was a test double for the obsolete `SignOutSessionStateManager` from `Microsoft.AspNetCore.Components.WebAssembly.Authentication` and has been removed. `AddAuthorization()` no longer registers it in the service collection.

src/bunit.template/template/CounterCSharpTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Company.BlazorTests1;
77
#if (testFramework_xunit)
88
public class CounterCSharpTest : BunitContext
99
#elif (testFramework_xunitv3)
10-
// The full qualified namespace for bUnit TestContext is used here as xunit v3 also offers a TestContext class
1110
public class CounterCSharpTest : BunitContext
1211
#elif (testFramework_nunit)
1312
public class CounterCSharpTest : BunitContext

src/bunit.template/template/CounterRazorTests.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@*#if (testFramework_xunit) *@
22
@inherits BunitContext
33
@*#elif (testFramework_xunitv3)*@
4-
@* The full qualified namespace for bUnit TestContext is used here as xunit v3 also offers a TestContext class *@
54
@inherits BunitContext
65
@*#elif (testFramework_nunit)*@
76
@inherits BunitContext

src/bunit/BunitContext.Obsoletes.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/bunit/Extensions/WaitForHelpers/WaitForFailedException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ time to complete the necessary number of renders of the component under test.
3838
and see if they match what is expected. If they do not,
3939
consider increasing the timeout, either at the individual
4040
method call level, e.g. WaitForElement("div", TimeSpan.FromSeconds(15)),
41-
or via the static TestContext.DefaultWaitTimeout property.
41+
or via the static BunitContext.DefaultWaitTimeout property.
4242
4343
Check count: {checkCount}.
4444
Component render count: {componentRenderCount}.

src/bunit/RemovedInFutureVersionAttribute.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/bunit/Rendering/MissingRendererInfoException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public sealed class MissingRendererInfoException : Exception
1010
/// </summary>
1111
public MissingRendererInfoException()
1212
: base("""
13-
A component under test is trying to access the 'RendererInfo' property, which has not been specified. Set it via TestContext.Renderer.SetRendererInfo.
13+
A component under test is trying to access the 'RendererInfo' property, which has not been specified. Set it via BunitContext.Renderer.SetRendererInfo.
1414
1515
For example:
1616
17-
public class SomeTestClass : TestContext
17+
public class SomeTestClass : BunitContext
1818
{
1919
[Fact]
2020
public void SomeTestCase()

src/bunit/TestContext.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/bunit/TestDoubles/Authorization/BunitAuthorizationExtensions.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Bunit.TestDoubles;
22
using Microsoft.AspNetCore.Components.Authorization;
3-
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
43

54
namespace Bunit;
65

@@ -11,16 +10,9 @@ public partial class BunitContext
1110
/// an authenticated user, as well as adding the <see cref="CascadingAuthenticationState"/> component to the
1211
/// test contexts render tree.
1312
/// </summary>
14-
[RemovedInFutureVersion("SignOutSessionStateManager should be removed from the container.")]
1513
public BunitAuthorizationContext AddAuthorization()
1614
{
1715
Services.AddCascadingAuthenticationState();
18-
#if !NET11_0_OR_GREATER
19-
Services.AddSingleton<BunitSignOutSessionStateManager>();
20-
#pragma warning disable CS0618
21-
Services.AddSingleton<SignOutSessionStateManager>(s => s.GetRequiredService<BunitSignOutSessionStateManager>());
22-
#pragma warning restore CS0618
23-
#endif
2416
var authCtx = new BunitAuthorizationContext(Services);
2517
return authCtx;
2618
}

0 commit comments

Comments
 (0)