Skip to content

BETA 5 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9d63a0d
Fixed spelling mistake in comment
egil Jan 6, 2020
e7b79ac
Reordered parameters to top of TestRenderer
egil Jan 6, 2020
457409c
Add support for asynchronous Razor tests (#27)
duracellko Jan 15, 2020
057e005
Dotnetconf samples (#33)
egil Jan 14, 2020
51d3a0f
Added unit tests of CompareTo, Generic and Collection assert extensions.
egil Jan 16, 2020
4925628
Added tests for general events and touch events dispatch extensions
egil Jan 16, 2020
26be467
Added tests for anglesharp extensions, JsRuntimeInvocation and Compon…
egil Jan 16, 2020
e99b1d7
Removed assert helpers that conflict with Shoudly
egil Jan 16, 2020
7dedd33
Tests of JsRuntimeAsserts
egil Jan 16, 2020
d077e11
Reorganized test library
egil Jan 16, 2020
ac61758
Suppressing warnings in sample
egil Jan 16, 2020
95f14fa
Changed ITestContext to have a CreateNodes method instead of HtmlPars…
egil Jan 16, 2020
751c43d
Removed empty test
egil Jan 16, 2020
e04e331
Added missing code documentation
egil Jan 16, 2020
9d50e6f
Moved MockJsRuntime to its own namespace
egil Jan 17, 2020
a9d65f6
Pulled sample from main solution into own solution
egil Jan 17, 2020
0af8b13
Update main.yml
egil Jan 17, 2020
31c4a4f
Change GetNodes and GetMarkup to Nodes and Markup properties in IRend…
egil Jan 20, 2020
c78be10
Add SetupVoid and SetVoidResult capabilities to JsRuntime mock (#35)
egil Jan 21, 2020
7411c68
Add default JsRuntime (#32)
Siphonophora Jan 22, 2020
7721421
Add .vscode to gitignore
egil Jan 22, 2020
6d57f19
TestServiceProvider now explictly implements IServiceCOlelction (#40)
egil Jan 22, 2020
ea034d1
Added async setup method to snapshot test
egil Jan 22, 2020
893fdad
Added test of SnapshotTests use of setup methods
egil Jan 22, 2020
865ea40
Update to readme
egil Jan 22, 2020
41f8ece
Merge branch 'master' into dev
egil Jan 22, 2020
d246f73
Removed duplicated MarkupMatches method
egil Jan 22, 2020
64faa76
Removed PR trigger
egil Jan 22, 2020
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
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

name: CI

on: [push, pull_request]
on: push

env:
VERSION: 1337.0.0
Expand All @@ -28,8 +28,10 @@ jobs:
dotnet-version: '3.1.100'
- name: Building and verifying library
run: |
dotnet build -c Release /nowarn:CS1591
dotnet build -c Release
dotnet test -c Release /nowarn:CS1591
dotnet build sample -c Release
dotnet test sample -c Release
- name: Creating library package
run: dotnet pack src/ -c Release -o ${GITHUB_WORKSPACE} -p:version=$VERSION /nowarn:CS1591
- name: Buidling template package
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bld/

# Visual Studio 2015/2017 cache/options directory
.vs/
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ This library's goal is to make it easy to write _comprehensive, stable unit test
- [Mocking JsRuntime](https://github.com/egil/razor-components-testing-library/wiki/Mocking-JsRuntime)
- [References](https://github.com/egil/razor-components-testing-library/wiki/References)
- [Contribute](https://github.com/egil/razor-components-testing-library/wiki/Contribute)

## Contributors

Shout outs and a big thank you to the contributors to this library. Here they are, in alphabetically:

- [Michael J Conrad (@Siphonophora)](https://github.com/Siphonophora)
- [Rastislav Novotný (@duracellko)](https://github.com/duracellko)
18 changes: 1 addition & 17 deletions Razor.Components.Testing.Library.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egil.RazorComponents.Testin
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egil.RazorComponents.Testing.Library.Tests", "tests\Egil.RazorComponents.Testing.Library.Tests.csproj", "{04E0142A-33CC-4E30-B903-F1370D94AD8C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{26D90CB9-AF66-4F42-A16E-39D2CF69C8FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egil.RazorComponents.Testing.Library.SampleApp", "sample\src\Egil.RazorComponents.Testing.Library.SampleApp.csproj", "{D1FE0F2A-D856-417E-A1FD-4ECE9C64D3AE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egil.RazorComponents.Testing.Library.SampleApp.Tests", "sample\tests\Egil.RazorComponents.Testing.Library.SampleApp.Tests.csproj", "{A7B05744-AA61-4F8E-8173-5DE812A4A745}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Razor.Components.Testing.Library.Template", "template\Razor.Components.Testing.Library.Template.csproj", "{FB46378D-BFB8-4C72-9CA3-0407D4665218}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egil.Razor.Components.Testing.Library.Template", "template\Egil.Razor.Components.Testing.Library.Template.csproj", "{FB46378D-BFB8-4C72-9CA3-0407D4665218}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -41,14 +35,6 @@ Global
{04E0142A-33CC-4E30-B903-F1370D94AD8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04E0142A-33CC-4E30-B903-F1370D94AD8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04E0142A-33CC-4E30-B903-F1370D94AD8C}.Release|Any CPU.Build.0 = Release|Any CPU
{D1FE0F2A-D856-417E-A1FD-4ECE9C64D3AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1FE0F2A-D856-417E-A1FD-4ECE9C64D3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1FE0F2A-D856-417E-A1FD-4ECE9C64D3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1FE0F2A-D856-417E-A1FD-4ECE9C64D3AE}.Release|Any CPU.Build.0 = Release|Any CPU
{A7B05744-AA61-4F8E-8173-5DE812A4A745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7B05744-AA61-4F8E-8173-5DE812A4A745}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7B05744-AA61-4F8E-8173-5DE812A4A745}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7B05744-AA61-4F8E-8173-5DE812A4A745}.Release|Any CPU.Build.0 = Release|Any CPU
{FB46378D-BFB8-4C72-9CA3-0407D4665218}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB46378D-BFB8-4C72-9CA3-0407D4665218}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB46378D-BFB8-4C72-9CA3-0407D4665218}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -60,8 +46,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{AA96790B-67C9-4141-ACDB-037C8DC092EC} = {E006E9A4-F554-46DF-838F-812956521F64}
{04E0142A-33CC-4E30-B903-F1370D94AD8C} = {C929375E-BD70-4B78-88C1-BDD1623C3365}
{D1FE0F2A-D856-417E-A1FD-4ECE9C64D3AE} = {26D90CB9-AF66-4F42-A16E-39D2CF69C8FB}
{A7B05744-AA61-4F8E-8173-5DE812A4A745} = {26D90CB9-AF66-4F42-A16E-39D2CF69C8FB}
{FB46378D-BFB8-4C72-9CA3-0407D4665218} = {E006E9A4-F554-46DF-838F-812956521F64}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
31 changes: 31 additions & 0 deletions sample/SampleApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "src\SampleApp.csproj", "{0C4F7AE0-EA8A-4ECC-9003-1CEE4412BBA7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp.Tests", "tests\SampleApp.Tests.csproj", "{04F6D258-F69C-4BB5-87C5-3813C3CE33D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0C4F7AE0-EA8A-4ECC-9003-1CEE4412BBA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C4F7AE0-EA8A-4ECC-9003-1CEE4412BBA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C4F7AE0-EA8A-4ECC-9003-1CEE4412BBA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C4F7AE0-EA8A-4ECC-9003-1CEE4412BBA7}.Release|Any CPU.Build.0 = Release|Any CPU
{04F6D258-F69C-4BB5-87C5-3813C3CE33D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04F6D258-F69C-4BB5-87C5-3813C3CE33D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04F6D258-F69C-4BB5-87C5-3813C3CE33D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04F6D258-F69C-4BB5-87C5-3813C3CE33D8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FBE5B0F6-5496-4BC5-BB38-CF16799DCF93}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Egil.RazorComponents.Testing.SampleApp</RootNamespace>
</PropertyGroup>

Expand Down
3 changes: 3 additions & 0 deletions sample/src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Diagnostics.CodeAnalysis;
using Egil.RazorComponents.Testing.SampleApp.Data;

namespace Egil.RazorComponents.Testing.SampleApp
{
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>")]
public class Startup
{
public Startup(IConfiguration configuration)
Expand All @@ -22,6 +24,7 @@ public Startup(IConfiguration configuration)

public IConfiguration Configuration { get; }


// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
Expand Down
1 change: 1 addition & 0 deletions sample/tests/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
6 changes: 6 additions & 0 deletions sample/tests/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "<Pending>", Scope = "member", Target = "~M:Egil.RazorComponents.Testing.SampleApp.Tests.Components.AlertTest2.Test008~System.Threading.Tasks.Task")]
10 changes: 5 additions & 5 deletions sample/tests/MockForecastService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Egil.RazorComponents.Testing.SampleApp
{
internal class MockForecastService : IWeatherForecastService
{
public TaskCompletionSource<WeatherForecast[]> Task { get; } = new TaskCompletionSource<WeatherForecast[]>();
internal class MockForecastService : IWeatherForecastService
{
public TaskCompletionSource<WeatherForecast[]> Task { get; } = new TaskCompletionSource<WeatherForecast[]>();

public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate) => Task.Task;
}
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate) => Task.Task;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@inherits TestComponentBase
@inherits TestComponentBase

@code {
MockJsRuntimeInvokeHandler MockJsRuntime { get; set; }
MockJsRuntimeInvokeHandler MockJsRuntime { get; set; } = default!;

void Setup()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
void Test()
{
var cut = GetComponentUnderTest<ThemedButton>();
var x = cut.GetMarkup();
cut.Find("button").ClassList.ShouldContain("btn");
}
}
2 changes: 1 addition & 1 deletion sample/tests/RazorTestComponents/Pages/FetchDataTest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

void Setup()
{
Services.AddService<IWeatherForecastService>(forecastService);
Services.AddSingleton<IWeatherForecastService>(forecastService);
}

void InitialLoadingHtmlRendersCorrectly()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Egil.RazorComponents.Testing.Library.csproj" />
<ProjectReference Include="..\src\Egil.RazorComponents.Testing.Library.SampleApp.csproj" />
<ProjectReference Include="..\src\SampleApp.csproj" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions sample/tests/Tests/Components/AlertTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System;
using System.Threading.Tasks;
using Egil.RazorComponents.Testing.Asserting;
using Egil.RazorComponents.Testing.EventDispatchExtensions;
using Egil.RazorComponents.Testing.Mocking.JSInterop;
using Egil.RazorComponents.Testing.SampleApp.Components;
using Egil.RazorComponents.Testing.SampleApp.Data;
using Microsoft.AspNetCore.Authentication;
Expand Down Expand Up @@ -208,7 +209,7 @@ public void Test007()
cut.MarkupMatches(string.Empty);
}

[Fact(DisplayName = "Alert can be dismissed via Dismiss() mehod")]
[Fact(DisplayName = "Alert can be dismissed via Dismiss() method")]
public async Task Test008()
{
// Arrange
Expand Down
3 changes: 3 additions & 0 deletions sample/tests/Tests/Components/FocussingInputTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System.Text;
using System.Threading.Tasks;
using Egil.RazorComponents.Testing.Asserting;
using Egil.RazorComponents.Testing.Mocking.JSInterop;
using Egil.RazorComponents.Testing.SampleApp.Components;
using Egil.RazorComponents.Testing.Mocking.JSInterop;
using Xunit;

namespace Egil.RazorComponents.Testing.SampleApp.CodeOnlyTests.Components
Expand All @@ -24,6 +26,7 @@ public void Test001()
// Assert
// that there is a single call to document.body.focus.call
var invocation = jsRtMock.VerifyInvoke("document.body.focus.call");

// Assert that the invocation received a single argument
// and that it was a reference to the input element.
var expectedReferencedElement = cut.Find("input");
Expand Down
6 changes: 4 additions & 2 deletions sample/tests/Tests/Components/TodoListTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Shouldly;
using AngleSharp.Dom;
using Egil.RazorComponents.Testing.Asserting;
using Egil.RazorComponents.Testing.Mocking.JSInterop;
using Egil.RazorComponents.Testing.EventDispatchExtensions;
using Egil.RazorComponents.Testing.Mocking.JSInterop;
using Egil.RazorComponents.Testing.SampleApp.Components;
using Egil.RazorComponents.Testing.SampleApp.Data;
using Microsoft.AspNetCore.Components;
Expand Down Expand Up @@ -119,8 +121,8 @@ public void Test005()
cut.Find("input").Change(taskValue);
cut.Find("form").Submit();

createdTask.ShouldNotBeNull();
createdTask?.Text.ShouldBe(taskValue);
createdTask = createdTask.ShouldBeOfType<Todo>();
createdTask.Text.ShouldBe(taskValue);
}

[Fact(DisplayName = "When add task form is submitted with no text OnAddingTodo is not called")]
Expand Down
1 change: 1 addition & 0 deletions sample/tests/Tests/Components/WikiSearchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Egil.RazorComponents.Testing.Asserting;
using Egil.RazorComponents.Testing.SampleApp.Components;
using Egil.RazorComponents.Testing.Mocking.JSInterop;
using Shouldly;
using Xunit;

Expand Down
5 changes: 3 additions & 2 deletions sample/tests/Tests/Pages/FetchDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Xunit;
using Egil.RazorComponents.Testing.SampleApp.Pages;
using Shouldly;
using Microsoft.Extensions.DependencyInjection;

namespace Egil.RazorComponents.Testing.SampleApp.CodeOnlyTests
{
Expand All @@ -17,7 +18,7 @@ public class FetchDataTest : ComponentTestFixture
public void Test001()
{
// Arrange - add the mock forecast service
Services.AddService<IWeatherForecastService, MockForecastService>();
Services.AddSingleton<IWeatherForecastService, MockForecastService>();

// Act - render the FetchData component
var cut = RenderComponent<FetchData>();
Expand All @@ -35,7 +36,7 @@ public void Test002()
// Setup the mock forecast service
var forecasts = new[] { new WeatherForecast { Date = DateTime.Now, Summary = "Testy", TemperatureC = 42 } };
var mockForecastService = new MockForecastService();
Services.AddService<IWeatherForecastService>(mockForecastService);
Services.AddSingleton<IWeatherForecastService>(mockForecastService);

// Arrange - render the FetchData component
var cut = RenderComponent<FetchData>();
Expand Down
7 changes: 4 additions & 3 deletions sample/tests/Tests/Pages/TodosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Egil.RazorComponents.Testing.SampleApp.Data;
using Egil.RazorComponents.Testing.EventDispatchExtensions;
using Egil.RazorComponents.Testing.SampleApp.Pages;
using Microsoft.Extensions.DependencyInjection;

namespace Egil.RazorComponents.Testing.SampleApp.CodeOnlyTests.Pages
{
Expand All @@ -30,7 +31,7 @@ public void Test001()
var getTask = new TaskCompletionSource<IReadOnlyList<Todo>>();
var todoSrv = new Mock<ITodoService>();
todoSrv.Setup(x => x.GetAll()).Returns(getTask.Task);
Services.AddService(todoSrv.Object);
Services.AddSingleton(todoSrv.Object);

// act
var page = RenderComponent<Todos>();
Expand All @@ -51,7 +52,7 @@ public void Test002()
var todos = new[] { new Todo { Id = 1, Text = "First" } };
var todoSrv = new Mock<ITodoService>();
todoSrv.Setup(x => x.GetAll()).Returns(Task.FromResult<IReadOnlyList<Todo>>(todos));
Services.AddService(todoSrv.Object);
Services.AddSingleton(todoSrv.Object);

// act
var page = RenderComponent<Todos>();
Expand All @@ -66,7 +67,7 @@ public void Test003()
{
// arrange
var todoSrv = new Mock<ITodoService>();
Services.AddService(todoSrv.Object);
Services.AddSingleton(todoSrv.Object);
var page = RenderComponent<Todos>();

// act
Expand Down
4 changes: 3 additions & 1 deletion sample/tests/_Imports.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.Extensions.DependencyInjection

@using Egil.RazorComponents.Testing
@using Egil.RazorComponents.Testing.EventDispatchExtensions
@using Egil.RazorComponents.Testing.Mocking.JSInterop
@using Egil.RazorComponents.Testing.Asserting

@using Egil.RazorComponents.Testing.SampleApp
Expand Down
1 change: 1 addition & 0 deletions src/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Egil.RazorComponents.Testing.Library.Tests")]
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace Egil.RazorComponents.Testing.Asserting
{
/// <summary>
/// Generic test assertions
/// Collection test assertions
/// </summary>
public static class GenericAssertExtensions
public static class CollectionAssertExtensions
{
/// <summary>
/// Verifies that a collection contains exactly a given number of elements, which
Expand Down
7 changes: 3 additions & 4 deletions src/Asserting/CompareToDiffingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ public static IReadOnlyList<IDiff> CompareTo(this IRenderedFragment actual, stri
if (actual is null) throw new ArgumentNullException(nameof(actual));
if (expected is null) throw new ArgumentNullException(nameof(expected));

var actualNodes = actual.GetNodes();
var expectedNodes = actual.TestContext.HtmlParser.Parse(expected);
var expectedNodes = actual.TestContext.CreateNodes(expected);

return actualNodes.CompareTo(expectedNodes);
return actual.Nodes.CompareTo(expectedNodes);
}

/// <summary>
Expand All @@ -43,7 +42,7 @@ public static IReadOnlyList<IDiff> CompareTo(this IRenderedFragment actual, IRen
if (actual is null) throw new ArgumentNullException(nameof(actual));
if (expected is null) throw new ArgumentNullException(nameof(expected));

return actual.GetNodes().CompareTo(expected.GetNodes());
return actual.Nodes.CompareTo(expected.Nodes);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Asserting/DiffAssertExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static IDiff ShouldHaveSingleChange(this IReadOnlyList<IDiff> diffs)
/// The total number of <see cref="IDiff"/> inspectors must exactly match the number of <see cref="IDiff"/>s in the collection</param>
public static void ShouldHaveChanges(this IReadOnlyList<IDiff> diffs, params Action<IDiff>[] diffInspectors)
{
Assert.Collection(diffs, diffInspectors);
CollectionAssertExtensions.ShouldAllBe(diffs, diffInspectors);
}

}
Expand Down
Loading