File tree Expand file tree Collapse file tree 10 files changed +82
-16
lines changed
bunit.web/Rendering/Internal Expand file tree Collapse file tree 10 files changed +82
-16
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ List of new features.
1313
1414- Added ` InvokeAsync(Func<Task>) ` to ` RenderedComponentInvokeAsyncExtensions ` . By [ @JeroenBos ] ( https://github.com/JeroenBos ) in [ #151 ] ( https://github.com/egil/bUnit/pull/177 ) .
1515- Added ` ITestRenderer Renderer { get ; } ` to ` IRenderedFragment ` to make it possible to simplify the ` IRenderedComponentBase<TComponent> ` interface. By [ @JeroenBos ] ( https://github.com/JeroenBos ) in [ #151 ] ( https://github.com/egil/bUnit/pull/177 ) .
16+ - Added support for scoped CSS to ` MarkupMatches ` and related comparer methods. By [ @egil ] ( https://github.com/egil ) in [ #195 ] ( https://github.com/egil/bUnit/pull/195 ) .
1617
1718### Changed
1819List of changes in existing functionality.
Original file line number Diff line number Diff line change 3636 </ItemGroup >
3737
3838 <ItemGroup Condition =" '$(TargetFramework)' == 'net5.0' AND $(MSBuildProjectName)!='bunit.template' AND $(MSBuildProjectName)!='bunit'" >
39- <PackageReference Include =" Microsoft.AspNetCore.Components.Authorization" Version =" 5.0.0-preview.7 .*" />
40- <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 5.0.0-preview.7 .*" />
41- <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 5.0.0-preview.7 .*" />
42- <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 5.0.0-preview.7 .*" />
43- <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 5.0.0-preview.7 .*" />
39+ <PackageReference Include =" Microsoft.AspNetCore.Components.Authorization" Version =" 5.0.0-preview.8 .*" />
40+ <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 5.0.0-preview.8 .*" />
41+ <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 5.0.0-preview.8 .*" />
42+ <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 5.0.0-preview.8 .*" />
43+ <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 5.0.0-preview.8 .*" />
4444 </ItemGroup >
4545
4646 <ItemGroup Condition =" $(MSBuildProjectName)!='bunit.template' AND $(MSBuildProjectName)!='bunit'" >
Original file line number Diff line number Diff line change @@ -26,11 +26,13 @@ internal class Htmlizer
2626 } ;
2727
2828 private const string BLAZOR_INTERNAL_ATTR_PREFIX = "__internal_" ;
29+ private const string BLAZOR_CSS_SCOPE_ATTR_PREFIX = "b-" ;
2930 public const string BLAZOR_ATTR_PREFIX = "blazor:" ;
3031 public const string ELEMENT_REFERENCE_ATTR_NAME = BLAZOR_ATTR_PREFIX + "elementreference" ;
3132
3233 public static bool IsBlazorAttribute ( string attributeName )
33- => attributeName . StartsWith ( BLAZOR_ATTR_PREFIX , StringComparison . Ordinal ) ;
34+ => attributeName . StartsWith ( BLAZOR_ATTR_PREFIX , StringComparison . Ordinal ) ||
35+ attributeName . StartsWith ( BLAZOR_CSS_SCOPE_ATTR_PREFIX , StringComparison . Ordinal ) ;
3436
3537 public static string ToBlazorAttribute ( string attributeName )
3638 {
Original file line number Diff line number Diff line change 1515 </ItemGroup >
1616
1717 <ItemGroup Condition =" '$(TargetFramework)' == 'net5.0' AND $(MSBuildProjectName)!='bunit.testassets'" >
18- <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 5.0.0-preview.7 .*" />
19- <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 5.0.0-preview.7 .*" />
20- <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 5.0.0-preview.7 .*" />
21- <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 5.0.0-preview.7 .*" />
18+ <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 5.0.0-preview.8 .*" />
19+ <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 5.0.0-preview.8 .*" />
20+ <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 5.0.0-preview.8 .*" />
21+ <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 5.0.0-preview.8 .*" />
2222 </ItemGroup >
2323
2424 <ItemGroup Condition =" $(MSBuildProjectName)!='bunit.testassets'" >
Original file line number Diff line number Diff line change 1+ <h1 >Hello Pink World!</h1 >
Original file line number Diff line number Diff line change 1+ h1 {
2+ color : deeppink;
3+ }
Original file line number Diff line number Diff line change 22
33 <PropertyGroup >
44 <TargetFrameworks >netstandard2.1;net5.0</TargetFrameworks >
5- <RazorLangVersion >3.0</RazorLangVersion >
65 <RootNamespace >Bunit.TestAssets</RootNamespace >
76 <AssemblyName >Bunit.TestAssets</AssemblyName >
87 <IsPackable >false</IsPackable >
1514 <WarningsAsErrors >CS8602;CS8603;CS8625</WarningsAsErrors >
1615 </PropertyGroup >
1716
17+ <PropertyGroup Condition =" '$(TargetFramework)' == 'netstandard2.1'" >
18+ <RazorLangVersion >3.0</RazorLangVersion >
19+ </PropertyGroup >
20+
1821 <ItemGroup Condition =" '$(TargetFramework)' == 'netstandard2.1'" >
1922 <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 3.1.1" />
2023 <PackageReference Include =" Microsoft.AspNetCore.Components.Authorization" Version =" 3.1.1" />
2124 <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 3.1.1" />
2225 </ItemGroup >
2326 <ItemGroup Condition =" '$(TargetFramework)' == 'net5.0'" >
24- <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 5.0.0-preview.7 .*" />
25- <PackageReference Include =" Microsoft.AspNetCore.Components.Authorization" Version =" 5.0.0-preview.7 .*" />
26- <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 5.0.0-preview.7 .*" />
27+ <PackageReference Include =" Microsoft.AspNetCore.Components" Version =" 5.0.0-preview.8 .*" />
28+ <PackageReference Include =" Microsoft.AspNetCore.Components.Authorization" Version =" 5.0.0-preview.8 .*" />
29+ <PackageReference Include =" Microsoft.AspNetCore.Components.Web" Version =" 5.0.0-preview.8 .*" />
2730 </ItemGroup >
2831
2932</Project >
Original file line number Diff line number Diff line change 1+ #if NET5_0
2+
3+ using System ;
4+ using System . Collections . Generic ;
5+ using System . Linq ;
6+ using System . Text ;
7+ using System . Threading . Tasks ;
8+
9+ using Bunit . TestAssets . SampleComponents ;
10+
11+ using Xunit ;
12+
13+ namespace Bunit
14+ {
15+ public partial class MarkupMatchesAssertExtensionsTest : TestContext
16+ {
17+ [ Fact ( DisplayName = "MarkupMatches correctly ignores scoped css attributes" ) ]
18+ public void Test_net5_001 ( )
19+ {
20+ var cut = RenderComponent < ScopedCssElements > ( ) ;
21+
22+ cut . MarkupMatches ( "<h1>Hello Pink World!</h1>" ) ;
23+ }
24+ }
25+ }
26+
27+ #endif
Original file line number Diff line number Diff line change 11using System ;
22using Bunit . TestAssets . BlazorE2E ;
3+ using Bunit . TestAssets . SampleComponents ;
4+
35using Microsoft . AspNetCore . Components ;
46using Microsoft . AspNetCore . Components . Rendering ;
57using Microsoft . AspNetCore . Components . Web ;
810
911namespace Bunit . Rendering . Internal
1012{
11- public class HtmlizerTests : TestContext
13+ public partial class HtmlizerTests : TestContext
1214 {
13- [ Theory ( DisplayName = "The component contains correctly prefixed internal attributes. " ) ]
15+ [ Theory ( DisplayName = "Htmlizer correctly prefixed stopPropagation and preventDefault attributes" ) ]
1416 [ InlineData ( false , true ) ]
1517 [ InlineData ( true , false ) ]
1618 [ InlineData ( true , true ) ]
Original file line number Diff line number Diff line change 1+ #if NET5_0
2+ using System ;
3+ using Bunit . TestAssets . BlazorE2E ;
4+ using Bunit . TestAssets . SampleComponents ;
5+
6+ using Microsoft . AspNetCore . Components ;
7+ using Microsoft . AspNetCore . Components . Rendering ;
8+ using Microsoft . AspNetCore . Components . Web ;
9+ using Shouldly ;
10+ using Xunit ;
11+
12+ namespace Bunit . Rendering . Internal
13+ {
14+ public partial class HtmlizerTests : TestContext
15+ {
16+ [ Theory ( DisplayName = "IsBlazorAttribute correctly identifies Blazor attributes" ) ]
17+ [ InlineData ( "b-twl12ishk1=\" \" " ) ]
18+ [ InlineData ( "blazor:onclick=\" 1\" " ) ]
19+ [ InlineData ( "blazor:__internal_stopPropagation_onclick=\" \" " ) ]
20+ [ InlineData ( "blazor:__internal_preventDefault_onclick=\" \" " ) ]
21+ public void TestNET5_001 ( string blazorAttribute )
22+ {
23+ Htmlizer . IsBlazorAttribute ( blazorAttribute ) . ShouldBeTrue ( ) ;
24+ }
25+ }
26+ }
27+ #endif
You can’t perform that action at this time.
0 commit comments