Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -117,7 +117,7 @@ jobs:

steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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 }}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup Label="Package Versioning">
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.8.118" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down Expand Up @@ -76,7 +76,7 @@
<PackageVersion Include="AutoFixture.Xunit3" Version="4.19.0"/>
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.6.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1"/>
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
Expand All @@ -88,11 +88,11 @@
<PackageVersion Include="Xunit.Combinatorial" Version="2.0.24"/>
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="nunit" Version="4.2.2" />
<PackageVersion Include="nunit" Version="4.4.0" />
<PackageVersion Include="xunit" Version="2.9.3"/>
<PackageVersion Include="xunit.v3" Version="3.1.0"/>
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.1.0" />
<PackageVersion Include="xunit.v3.assert" Version="3.1.0"/>
<PackageVersion Include="xunit.v3" Version="3.2.0"/>
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.0" />
<PackageVersion Include="xunit.v3.assert" Version="3.2.0"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5"/>
</ItemGroup>

Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/bUnit-de

<table border="0">
<tr>
<td align="center" width="120">
<a href="https://www.syncfusion.com/blazor-components?utm_source=bunit&utm_medium=cpc&utm_campaign=bunit_blazor_bancy25">
<img class="avatar" src="https://avatars.githubusercontent.com/u/1699795?s=460" width="72" height="72" alt="@syncfusion" />
<br />
Syncfusion
</a>
</td>
<td align="center" width="250">
<a href="https://www.lambdatest.com/?utm_source=bunit&utm_medium=sponsor" target="_blank">
<img src="https://www.lambdatest.com/blue-logo.png" style="vertical-align: middle;" width="250" height="45" />
Expand Down
7 changes: 7 additions & 0 deletions src/bunit/RemovedInFutureVersionAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Bunit;

[AttributeUsage(AttributeTargets.All, Inherited = false)]
internal sealed class RemovedInFutureVersionAttribute(string todo) : Attribute
{
public string Todo { get; } = todo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public partial class BunitContext
/// an authenticated user, as well as adding the <see cref="CascadingAuthenticationState"/> component to the
/// test contexts render tree.
/// </summary>
[RemovedInFutureVersion("SignOutSessionStateManager should be removed from the container.")]
public BunitAuthorizationContext AddAuthorization()
{
RenderTree.TryAdd<CascadingAuthenticationState>();
Services.AddCascadingAuthenticationState();
Services.AddSingleton<BunitSignOutSessionStateManager>();
#pragma warning disable CS0618
Services.AddSingleton<SignOutSessionStateManager>(s => s.GetRequiredService<BunitSignOutSessionStateManager>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Bunit.TestDoubles;
/// that will help later to assert if the user was logged out
/// </summary>
#pragma warning disable CS0618
[RemovedInFutureVersion("SignOutSessionStateManager is obsolete")]
public class BunitSignOutSessionStateManager : SignOutSessionStateManager
#pragma warning restore CS0618
{
Expand Down
19 changes: 19 additions & 0 deletions tests/bunit.tests/TestDoubles/Components/StubTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.AspNetCore.Components.Authorization;

namespace Bunit.TestDoubles.Components;

public class StubTest : BunitContext
Expand Down Expand Up @@ -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<AuthTestComponent>();

cut.Instance.Auth.ShouldNotBeNull();
}

private sealed class AuthTestComponent : ComponentBase
{
[CascadingParameter]
public Task<AuthenticationState> Auth { get; set; } = null!;
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
Loading