Skip to content

Commit 4af67eb

Browse files
committed
Test and Snapshop tests
1 parent 78b58a3 commit 4af67eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+647
-1764
lines changed

Directory.Build.props

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
<Project>
2-
<PropertyGroup>
3-
<AspNetCoreVersion>3.0.0</AspNetCoreVersion>
4-
</PropertyGroup>
5-
</Project>
2+
<PropertyGroup>
3+
<AspNetCoreVersion>3.1.0-preview1.19508.20</AspNetCoreVersion>
4+
</PropertyGroup>
5+
6+
<PropertyGroup>
7+
<LangVersion>8.0</LangVersion>
8+
<Nullable>enable</Nullable>
9+
<WarningsAsErrors>CS8600;CS8602;CS8603;CS8625</WarningsAsErrors>
10+
</PropertyGroup>
11+
12+
<PropertyGroup>
13+
<AnnotatedReferenceAssemblyVersion>3.0.0</AnnotatedReferenceAssemblyVersion>
14+
</PropertyGroup>
15+
<ItemGroup>
16+
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.90" PrivateAssets="all" />
17+
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(AnnotatedReferenceAssemblyVersion)]" />
18+
</ItemGroup>
19+
20+
</Project>

src/AngleSharp.Diffing/Diff.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/AngleSharp.Diffing/DiffBuilder.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Diffing/HtmlComparer.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using AngleSharp.Diffing.Strategies;
4+
using AngleSharp.Diffing;
5+
using AngleSharp.Html.Parser;
6+
using AngleSharp;
7+
using AngleSharp.Dom;
8+
using AngleSharp.Diffing.Core;
9+
10+
namespace Egil.RazorComponents.Testing
11+
{
12+
public sealed class HtmlComparer : IHtmlComparer
13+
{
14+
private readonly IBrowsingContext _context;
15+
private readonly IHtmlParser _htmlParser;
16+
private readonly IDocument _document;
17+
private readonly HtmlDifferenceEngine _differenceEngine;
18+
19+
public HtmlComparer()
20+
{
21+
var diffOptions = new DiffingStrategyPipeline();
22+
diffOptions.AddDefaultOptions();
23+
_differenceEngine = new HtmlDifferenceEngine(diffOptions);
24+
var config = Configuration.Default.WithCss();
25+
_context = BrowsingContext.New(config);
26+
_htmlParser = _context.GetService<IHtmlParser>();
27+
_document = _context.OpenNewAsync().Result;
28+
}
29+
30+
public List<IDiff> Compare(string controlHtml, string testHtml)
31+
{
32+
return _differenceEngine.Compare(Parse(controlHtml), Parse(testHtml)).ToList();
33+
}
34+
35+
public void Dispose()
36+
{
37+
_document.Dispose();
38+
}
39+
40+
private INodeList Parse(string html)
41+
{
42+
return _htmlParser.ParseFragment(html, _document.Body);
43+
}
44+
}
45+
}

src/Diffing/HtmlDifferenceEvaluators.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/Diffing/RazorComponentDoesNotMatchException.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/Diffing/RazorComponentsMatchException.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Diffing/XmlNodeAssertExtensions.cs

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/Egil.RazorComponents.Testing.Library.csproj

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
<RootNamespace>Egil.RazorComponents.Testing</RootNamespace>
55
<TargetFramework>netstandard2.0</TargetFramework>
66
<RazorLangVersion>3.0</RazorLangVersion>
7-
<LangVersion>8.0</LangVersion>
8-
<Nullable>enable</Nullable>
9-
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
107
<PackageId>Razor.Components.Testing.Library</PackageId>
118
<PackageLicenseExpression></PackageLicenseExpression>
129
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1310
<RepositoryUrl>https://github.com/egil/razor-components-testing-library</RepositoryUrl>
11+
<RepositoryType>git</RepositoryType>
1412
<PackageProjectUrl>https://github.com/egil/razor-components-testing-library</PackageProjectUrl>
1513
<PackageTags>razor-components unit-testing testing blazor blazor-server-side blazor-client-side</PackageTags>
1614
<Version>0.1.0-preview9-19424-4-3</Version>
@@ -20,21 +18,26 @@
2018
<Description>
2119
Testing library for Razor Components, that allows you to easily define your component under test and the expected output HTML in a .razor files. See the projects GitHub page for usage details: https://github.com/egil/razor-components-testing-library
2220
</Description>
21+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
22+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
23+
<IncludeSymbols>true</IncludeSymbols>
24+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2325
</PropertyGroup>
2426

27+
<ItemGroup>
28+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19554-01" PrivateAssets="All" />
29+
</ItemGroup>
30+
2531
<ItemGroup>
2632
<PackageReference Include="AngleSharp" Version="0.13.0" />
27-
<PackageReference Include="Microsoft.AspNetCore.Components" Version="$(AspNetCoreVersion)" />
28-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(AspNetCoreVersion)" />
29-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="2.9.4">
30-
<PrivateAssets>all</PrivateAssets>
31-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32-
</PackageReference>
33-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4">
33+
<PackageReference Include="AngleSharp.Css" Version="0.13.0" />
34+
<PackageReference Include="AngleSharp.Diffing" Version="0.13.0-preview-2" />
35+
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.0-preview2.19528.8" />
36+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.0-preview2.19528.8" />
37+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7">
3438
<PrivateAssets>all</PrivateAssets>
3539
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3640
</PackageReference>
37-
<PackageReference Include="XMLUnit.Core" Version="2.7.1" />
3841
<PackageReference Include="xunit.assert" Version="2.4.1" />
3942
<PackageReference Include="xunit.extensibility.core" Version="2.4.1" />
4043
</ItemGroup>

0 commit comments

Comments
 (0)