Skip to content

Commit

Permalink
Merge pull request #957 from bUnit-dev/release/v1.14
Browse files Browse the repository at this point in the history
Release of new minor version v1.14
  • Loading branch information
egil authored Jan 11, 2023
2 parents e961bf7 + 85d2a77 commit 7843cbf
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to **bUnit** will be documented in this file. The project ad

## [Unreleased]

### Added

- Added `IMemoryCache` by default to the Services container. By [@linkdotnet](https://github.com/linkdotnet).

### Fixed

- Added support in `FakeNavigationManager` to handle umlauts.
- Fixed a bug where attribute values did not get escaped. Reported by [@brettwinters](https://github.com/brettwinters). Fixed by [@linkdotnet](https://github.com/linkdotnet).

## [1.13.5] - 2022-12-16

This release contains a bunch of small tweaks and fixes.
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<!-- Shared code analyzers used for all projects in the solution -->
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.51.0.59060" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Implicit usings"
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ A huge thank you to the [sponsors of my work with bUnit](https://github.com/spon
<table border="0">
<tr>
<td align="center" width="120">
<a href="https://github.com/telerik">
<img src="https://avatars.githubusercontent.com/u/568561?s=200&v=4" alt="@Telerik" class="avatar" width="72" height="72" />
<a href="https://github.com/Progress-Telerik">
<img src="https://avatars.githubusercontent.com/u/57092419?s=460" alt="@Progress-Telerik" class="avatar" width="72" height="72" />
<br />
Telerik
Progress Telerik
</a>
</td>
<td align="center" width="120">
Expand All @@ -56,7 +56,14 @@ A huge thank you to the [sponsors of my work with bUnit](https://github.com/spon
<br />
Syncfusion
</a>
</td>
</td>
<td align="center" width="120">
<a href="https://github.com/aws">
<img class="avatar" src="https://avatars.githubusercontent.com/u/2232217?s=200&v=4" width="72" height="72" alt="@aws" />
<br />
Amazon Web Services
</a>
</td>
<td align="center" width="120">
<a href="https://github.com/hassanhabib">
<img src="https://avatars.githubusercontent.com/u/1453985?s=460" alt="Hassan Rezk Habib (@hassanhabib)" width="72" height="72" class="avatar" />
Expand Down
2 changes: 1 addition & 1 deletion benchmark/bunit.benchmarks/bunit.benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.3" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/bunit.web/Extensions/TestServiceProviderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Localization;

namespace Bunit.Extensions;
Expand Down Expand Up @@ -54,6 +55,8 @@ public static IServiceCollection AddDefaultTestContextServices(this IServiceColl
services.AddSingleton<BunitHtmlParser>();
services.AddSingleton<IRenderedComponentActivator, RenderedComponentActivator>();

services.AddMemoryCache();

#if NET6_0_OR_GREATER
services.AddSingleton<IErrorBoundaryLogger, BunitErrorBoundaryLogger>();
#endif
Expand Down
8 changes: 7 additions & 1 deletion src/bunit.web/Rendering/Internal/Htmlizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Globalization;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using Bunit.Rendering;

namespace Bunit;
Expand Down Expand Up @@ -270,7 +271,7 @@ private static int RenderAttributes(
result.Append(frame.AttributeName);
result.Append('=');
result.Append('"');
result.Append(value);
result.Append(Escape(value));
result.Append('"');
break;
default:
Expand All @@ -281,6 +282,11 @@ private static int RenderAttributes(
return position + maxElements;
}

private static string Escape(string value) =>
value
.Replace("&", "&amp;", StringComparison.OrdinalIgnoreCase)
.Replace("\"", "&quot;", StringComparison.OrdinalIgnoreCase);

private sealed class HtmlRenderingContext
{
private readonly RenderTreeFrameDictionary frames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ protected override void HandleLocationChangingHandlerException(Exception ex, Loc
#endif

private URI GetNewAbsoluteUri(string uri)
=> URI.IsWellFormedUriString(uri, UriKind.Relative)
? ToAbsoluteUri(uri)
: new URI(uri, UriKind.Absolute);
=> new URI(uri, UriKind.RelativeOrAbsolute).IsAbsoluteUri
? new URI(uri, UriKind.RelativeOrAbsolute) : ToAbsoluteUri(uri);

private bool HasDifferentBaseUri(URI absoluteUri)
=> URI.Compare(
Expand Down
6 changes: 5 additions & 1 deletion src/bunit.web/bunit.web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet3Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet3Version)" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet3Version)" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet3Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.1" />
</ItemGroup>
Expand All @@ -32,13 +33,15 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet5Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet5Version)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet6Version)" />
Expand All @@ -47,6 +50,7 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(DotNet7Version)" />
Expand Down Expand Up @@ -82,4 +86,4 @@
<Using Include="Microsoft.JSInterop" />
</ItemGroup>

</Project>
</Project>
4 changes: 2 additions & 2 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<ItemGroup Condition="$(MSBuildProjectName) != 'bunit.testassets'">
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Xunit.Combinatorial" Version="1.5.25" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<p style="@Escaped">@Escaped</p>

@code {
private string Escaped => "url('')";

[Parameter]
public string Escaped { get; set; }

}
8 changes: 5 additions & 3 deletions tests/bunit.web.tests/BlazorE2E/ComponentRenderingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,13 @@ public async Task CanHandleRemovedParentObjectsAsync()
}

[Fact]
public void EscapableCharactersDontGetEncoded()
public void SomeEscapableCharactersDontGetEncoded()
{
var cut = RenderComponent<ComponentWithEscapableCharacters>();
const string input = "url('\"&')";
var cut = RenderComponent<ComponentWithEscapableCharacters>(
p => p.Add(s => s.Escaped, input));

cut.Markup.ShouldBe("<p style=\"url('')\">url('')</p>");
cut.Markup.ShouldBe("<p style=\"url('&quot;&amp;')\">url('\"&')</p>");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public void Test002()
[InlineData("")]
[InlineData("/")]
[InlineData("/foo")]
[InlineData("/#Storstädning")]
[InlineData("/#åäö")]
public void Test003(string uri)
{
var sut = CreateFakeNavigationManager();
Expand Down
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/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.13",
"version": "1.14",
"assemblyVersion": {
"precision": "revision"
},
Expand Down

0 comments on commit 7843cbf

Please sign in to comment.