Skip to content

Commit

Permalink
Merge pull request #697 from bUnit-dev/release/v1.7
Browse files Browse the repository at this point in the history
Release of new minor version v1.7
  • Loading branch information
egil authored Apr 29, 2022
2 parents 3970922 + 680ec77 commit 9c395bc
Show file tree
Hide file tree
Showing 52 changed files with 803 additions and 180 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ dotnet_diagnostic.BL0003.severity = none
dotnet_diagnostic.BL0004.severity = none
dotnet_diagnostic.BL0005.severity = none
dotnet_diagnostic.BL0006.severity = none
dotnet_diagnostic.BL0007.severity = none

##########################################
# Custom Test Code Analyzers Rules
Expand Down
10 changes: 10 additions & 0 deletions .github/nightly-failed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Verification against .NET 7 nightly failed
labels: input needed
---

The nightly build failed against the nightly .NET 7 SDK. Please investigate.

## Additional information

`dotnet --version`: `{{env.DOTNET_VERSION}}`
26 changes: 13 additions & 13 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ jobs:
with:
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'

- name: ⚙️ Setup dotnet 3.1.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
with:
dotnet-version: '3.1.x'

- name: ⚙️ Setup dotnet 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'

- name: ⚙️ Setup dotnet 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true
- name: 🎨 Setup color
run: |
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
echo "TERM=xterm" >> $GITHUB_ENV
- name: 🛠️ Building bUnit
run: dotnet build /p:PublicRelease=true
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/release-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ jobs:
- name: ⚙️ Setup GIT versioning
uses: dotnet/[email protected]

- name: ⚙️ Setup dotnet 5.0.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
with:
dotnet-version: '5.0.x'

- name: ⚙️ Setup dotnet 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true

- name: 🎨 Setup color
run: |
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
echo "TERM=xterm" >> $GITHUB_ENV
- name: 🛠️ Update tokens in project files
uses: cschleiden/replace-tokens@v1
Expand All @@ -50,8 +55,8 @@ jobs:
dotnet pack src/bunit.template/ -c Release -o ${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true
- name: 🛠️ Upload library to GitHub Package Repository
run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bunit-dev/index.json --skip-duplicate --no-symbols true
run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bunit-dev/index.json --skip-duplicate --no-symbols

- name: 🛠️ Upload library to NuGet.org repository
if: github.event.inputs.nugetRelease == 'true'
run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols true
run: dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ jobs:
with:
setAllVars: true

- name: ⚙️ Setup dotnet 5.0.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
with:
dotnet-version: '5.0.x'

- name: ⚙️ Setup dotnet 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true

- name: 🛠️ Update changelog
uses: thomaseizinger/[email protected]
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/verification-dotnet-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: verification-dotnet-nightly

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
verify-bunit:
name: 👌 Verify bUnit
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/nightly/sdk:7.0

steps:
- name: 🌛 Show dotnet version
run: |
dotnet --info
- name: 🛒 Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: 🎨 Setup color
run: |
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
echo "TERM=xterm" >> $GITHUB_ENV
- name: 📦 Setup nuget nightly builds
run: |
dotnet restore --verbosity normal -s https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json -s https://api.nuget.org/v3/index.json
- name: 🧪 Run unit tests
run: |
dotnet test ./tests/bunit.core.tests/bunit.core.tests.csproj -c release --no-restore -f net7.0 --logger:"console;verbosity=normal" --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.web.tests/bunit.web.tests.csproj -c release --no-restore -f net7.0 --logger:"console;verbosity=normal" --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj -c release --no-restore -f net7.0 --logger:"console;verbosity=normal" --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
- name: 🧾 Collect dotnet information
if: failure()
run: |
echo "DOTNET_VERSION=$(dotnet --version)" >> $GITHUB_ENV
echo $DOTNET_VERSION
- name: ⚡ Create issue if failed
if: failure()
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADJECTIVE: DOTNET_VERSION
with:
filename: .github/nightly-failed.md
update_existing: true
32 changes: 16 additions & 16 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ jobs:
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 3.1.x
uses: actions/setup-dotnet@v1
- name: ⚙️ Setup dotnet versions
uses: actions/setup-dotnet@v2
with:
dotnet-version: '3.1.x'

- name: ⚙️ Setup dotnet 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'

- name: ⚙️ Setup dotnet 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
include-prerelease: true

- name: 🎨 Setup color
run: |
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
echo "TERM=xterm" >> $GITHUB_ENV
- name: ⚙️ Setup GIT versioning
uses: dotnet/[email protected]
Expand All @@ -63,9 +63,9 @@ jobs:

- name: 🧪 Run unit tests
run: |
dotnet test ./tests/bunit.core.tests/bunit.core.tests.csproj -c release --logger GitHubActions --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.web.tests/bunit.web.tests.csproj -c release --logger GitHubActions --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj -c release --logger GitHubActions --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.core.tests/bunit.core.tests.csproj -c release --logger:"console;verbosity=normal" --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.web.tests/bunit.web.tests.csproj -c release --logger:"console;verbosity=normal" --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
dotnet test ./tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj -c release --logger:"console;verbosity=normal" --blame-hang --blame-hang-timeout 1m --blame-hang-dump-type none
- name: 🗳️ Pack library
run: |
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ All notable changes to **bUnit** will be documented in this file. The project ad

## [Unreleased]

### Added

- Added method `SetAuthenticationType` to `TestAuthorizationContext` to allow for custom authentication type checks. By [@TimPurdum](https://github.com/timpurdum).

- Added `DisposeComponents` to `TestContextBase`. It will dispose and remove all components rendered by the `TestContextBase`. By [@linkdotnet](https://github.com/linkdotnet).

- Added .NET 7 as a target framework for bUnit. By [@linkdotnet](https://github.com/linkdotnet).

### Fixed

- Fixed step by step guide for building and viewing the documentation locally. By [@linkdotnet](https://github.com/linkdotnet).

- `FakeNavigationManager.NavigateTo` could lead to exceptions when navigating to external url's. Reported by (@TDroogers)[https://github.com/TDroogers]. Fixed by [@linkdotnet](https://github.com/linkdotnet).

## [1.6.4] - 2022-02-22

A quick minor release that primiarily fixes a regression in 1.5.12.
Expand Down
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<DotNet3Version>3.1.22</DotNet3Version>
<DotNet5Version>5.0.0</DotNet5Version>
<DotNet6Version>6.0.0</DotNet6Version>
<DotNet7Version>7.0.0-*</DotNet7Version>
</PropertyGroup>

<!-- Solution wide properties -->
Expand Down Expand Up @@ -47,8 +48,8 @@
<!-- Shared code analyzers used for all projects in the solution -->
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.5.1" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.695" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.35.0.42613" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.701" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.38.0.46746" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Implicit usings" Condition="$(MSBuildProjectName) != 'bunit.template' AND $(MSBuildProjectName) != 'bunit'">
Expand Down
14 changes: 11 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ These sample components, source files, and tests source files are included in th

## Building and Viewing Docs Locally

To build and view the documentation locally, follow these steps:
The following chapter describes how you can run and view the documentation locally

### Requirements
You will need the following tools installed:
* The [`dotnet serve` tool](https://github.com/natemcmaster/dotnet-serve)
* [DocFx](https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html#2-use-docfx-as-a-command-line-tool) to generate the html files

### View the documentation

1. From `docs/site` run `dotnet build`. If you get warnings from running `dotnet build`, try running it again.
2. From `docs/` run `serve-docs.cmd`. This will start up a local web server, hosting the generated documentation site on http://localhost:8080, using the [`dotnet serve` tool](https://github.com/natemcmaster/dotnet-serve).
3. After changing samples from `docs/samples`, run `dotnet test`. This will compile the sample components and run the sample tests.
2. From `docs/` run `docfx`. This will generate all the html site based on the markdown files.
3. From `docs/` run `serve-docs.cmd`. This will start up a local web server, hosting the generated documentation site.
4. After changing samples from `docs/samples`, run `dotnet test`. This will compile the sample components and run the sample tests.

## Documentation Writing Rules

Expand Down
21 changes: 21 additions & 0 deletions docs/samples/components/DisposableComponent.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@using Microsoft.AspNetCore.Components.Routing
@implements IDisposable
@inject NavigationManager NavigationManager
@code {
[Parameter] public Action<string> LocationChangedCallback { get; set; }

protected override void OnInitialized()
{
NavigationManager.LocationChanged += OnLocationChanged;
}

public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}

private void OnLocationChanged(object sender, LocationChangedEventArgs e)
{
LocationChangedCallback(e.Location);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@implements IAsyncDisposable
@code {
public async ValueTask DisposeAsync()
{
await Task.Delay(10);
throw new NotSupportedException();
}
}
7 changes: 7 additions & 0 deletions docs/samples/components/ExceptionInDisposeComponent.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@implements IDisposable
@code {
public void Dispose()
{
throw new NotSupportedException();
}
}
6 changes: 6 additions & 0 deletions docs/samples/components/UserRights.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<AuthorizeView Policy="content-editor">
<li>You are a CONTENT EDITOR</li>
</AuthorizeView>
<AuthorizeView>
@if(context.User.Identity?.AuthenticationType == "custom-auth-type")
{
<li>You have the authentication type CUSTOM AUTH TYPE</li>
}
</AuthorizeView>
</ul>

@code
Expand Down
49 changes: 49 additions & 0 deletions docs/samples/tests/xunit/DisposeComponentsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace Bunit.Docs.Samples;

public class DisposeComponentsTest
{
[Fact]
public void DisposeElements()
{
using var ctx = new TestContext();
var calledTimes = 0;
var cut = ctx.RenderComponent<DisposableComponent>(parameters => parameters
.Add(p => p.LocationChangedCallback, url => calledTimes++)
);

ctx.DisposeComponents();

ctx.Services.GetRequiredService<NavigationManager>().NavigateTo("newurl");

Assert.Equal(0, calledTimes);
}

[Fact]
public void ShouldCatchExceptionInDispose()
{
using var ctx = new TestContext();
ctx.RenderComponent<ExceptionInDisposeComponent>();

var act = ctx.DisposeComponents;

Assert.Throws<NotSupportedException>(act);
}

#if NET5_0_OR_GREATER
[Fact]
public void ShouldCatchExceptionInDisposeAsync()
{
using var ctx = new TestContext();
ctx.RenderComponent<ExceptionInDisposeAsyncComponent>();

ctx.DisposeComponents();
var exception = ctx.Renderer.UnhandledException.Result;
Assert.IsType<NotSupportedException>(exception);
}
#endif
}
Loading

0 comments on commit 9c395bc

Please sign in to comment.