diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fa502cf8..017ee69f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: create-nuget: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: fetch-depth: 0 # Get all history to allow automatic versioning using MinVer @@ -77,7 +77,7 @@ jobs: dotnet pack src/bunit.generators/ -c release --output ${{ env.NUGET_DIRECTORY }} -p:ContinuousIntegrationBuild=true -p:publicrelease=true # Publish the NuGet package as an artifact, so they can be used in the following jobs - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 with: name: ${{ env.NUGET_PACKAGES_ARTIFACT }} if-no-files-found: error @@ -92,7 +92,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v5 - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: name: ${{ env.NUGET_PACKAGES_ARTIFACT }} path: ${{ env.NUGET_DIRECTORY }} @@ -117,7 +117,7 @@ jobs: steps: - name: 🛒 Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 @@ -139,7 +139,7 @@ jobs: - name: 📛 Upload hang- and crash-dumps on test failure if: success() || failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: if-no-files-found: ignore name: test-dumps @@ -151,7 +151,7 @@ jobs: runs-on: ubuntu-latest needs: [ create-nuget ] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: fetch-depth: 0 # Get all history to allow automatic versioning using MinVer @@ -161,7 +161,7 @@ jobs: dotnet-version: | 9.0.x - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: name: ${{ env.NUGET_PACKAGES_ARTIFACT }} path: ${{ env.NUGET_DIRECTORY }} @@ -211,7 +211,7 @@ jobs: runs-on: ubuntu-latest steps: - name: 🛒 Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 @@ -264,7 +264,7 @@ jobs: if: github.event_name == 'pull_request' && github.repository_owner == 'bunit-dev' steps: - name: 'Checkout Repository' - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: 'Dependency Review' uses: actions/dependency-review-action@v4 @@ -275,7 +275,7 @@ jobs: permissions: id-token: write steps: - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: name: ${{ env.NUGET_PACKAGES_ARTIFACT }} path: ${{ env.NUGET_DIRECTORY }} diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index 22a8a40f0..ce8f2a843 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -30,7 +30,7 @@ jobs: steps: - name: 🛒 Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 token: ${{ secrets.BUNIT_BOT_TOKEN }} diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index ce719314d..7fc66628c 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -16,7 +16,7 @@ jobs: if: github.ref == 'refs/heads/main' && contains(fromJson('["major","minor"]'), github.event.inputs.versionIncrement) steps: - name: 🛒 Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 token: ${{ secrets.BUNIT_BOT_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e28b01c6..165efa684 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,10 +28,13 @@ jobs: runs-on: ubuntu-latest permissions: id-token: write + contents: write + issues: write + pull-requests: write steps: - name: 🛒 Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 token: ${{ secrets.BUNIT_BOT_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index b9de2cd4d..d7d63bd15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to **bUnit** will be documented in this file. The project ad ## [Unreleased] +### Changed +- Registering `AuthenticationState` in the services container rather than as part of the RenderTree. Fixes [#1774](https://github.com/bUnit-dev/bUnit/issues/1774) reported by [@aayjaychan](https://github.com/aayjaychan). + ## [2.0.66] - 2025-11-11 This major release focuses on platform updates and API simplifications. diff --git a/Directory.Packages.props b/Directory.Packages.props index 1a6bd7d3b..73e40e4e4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -23,7 +23,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -88,11 +88,11 @@ - + - - - + + + diff --git a/README.md b/README.md index d9ef65804..98ab4b82f 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,6 @@ A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/bUnit-de -
- - @syncfusion -
- Syncfusion -
-
diff --git a/src/bunit/RemovedInFutureVersionAttribute.cs b/src/bunit/RemovedInFutureVersionAttribute.cs new file mode 100644 index 000000000..3330d9252 --- /dev/null +++ b/src/bunit/RemovedInFutureVersionAttribute.cs @@ -0,0 +1,7 @@ +namespace Bunit; + +[AttributeUsage(AttributeTargets.All, Inherited = false)] +internal sealed class RemovedInFutureVersionAttribute(string todo) : Attribute +{ + public string Todo { get; } = todo; +} diff --git a/src/bunit/TestDoubles/Authorization/BunitAuthorizationExtensions.cs b/src/bunit/TestDoubles/Authorization/BunitAuthorizationExtensions.cs index cb7c5ad83..3bf3677f1 100644 --- a/src/bunit/TestDoubles/Authorization/BunitAuthorizationExtensions.cs +++ b/src/bunit/TestDoubles/Authorization/BunitAuthorizationExtensions.cs @@ -11,9 +11,10 @@ public partial class BunitContext /// an authenticated user, as well as adding the component to the /// test contexts render tree. /// + [RemovedInFutureVersion("SignOutSessionStateManager should be removed from the container.")] public BunitAuthorizationContext AddAuthorization() { - RenderTree.TryAdd(); + Services.AddCascadingAuthenticationState(); Services.AddSingleton(); #pragma warning disable CS0618 Services.AddSingleton(s => s.GetRequiredService()); diff --git a/src/bunit/TestDoubles/NavigationManager/BunitSignOutSessionStateManager.cs b/src/bunit/TestDoubles/NavigationManager/BunitSignOutSessionStateManager.cs index 66dc01802..b84699201 100644 --- a/src/bunit/TestDoubles/NavigationManager/BunitSignOutSessionStateManager.cs +++ b/src/bunit/TestDoubles/NavigationManager/BunitSignOutSessionStateManager.cs @@ -7,6 +7,7 @@ namespace Bunit.TestDoubles; /// that will help later to assert if the user was logged out /// #pragma warning disable CS0618 +[RemovedInFutureVersion("SignOutSessionStateManager is obsolete")] public class BunitSignOutSessionStateManager : SignOutSessionStateManager #pragma warning restore CS0618 { diff --git a/tests/bunit.tests/TestDoubles/Components/StubTest.cs b/tests/bunit.tests/TestDoubles/Components/StubTest.cs index 0f15283cb..badf4a6dd 100644 --- a/tests/bunit.tests/TestDoubles/Components/StubTest.cs +++ b/tests/bunit.tests/TestDoubles/Components/StubTest.cs @@ -1,3 +1,5 @@ +using Microsoft.AspNetCore.Components.Authorization; + namespace Bunit.TestDoubles.Components; public class StubTest : BunitContext @@ -25,4 +27,21 @@ public void Test002(string header, string attrValue) ps => ps.ShouldContain(x => x.Key == nameof(Simple1.AttrValue) && attrValue.Equals(x.Value)), ps => ps.Count.ShouldBe(2)); } + + [Fact(DisplayName = "Stubbing everything except cut keeps cascading AuthenticationState")] + public void Test003() + { + AddAuthorization(); + ComponentFactories.AddStub(c => c != typeof(AuthTestComponent)); + + var cut = Render(); + + cut.Instance.Auth.ShouldNotBeNull(); + } + + private sealed class AuthTestComponent : ComponentBase + { + [CascadingParameter] + public Task Auth { get; set; } = null!; + } } diff --git a/version.json b/version.json index c899fde1b..1bddb4867 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.0", + "version": "2.1", "assemblyVersion": { "precision": "revision" },