Skip to content

Commit b5a823c

Browse files
committed
Preview 1 release
1 parent e4502f6 commit b5a823c

23 files changed

Lines changed: 154 additions & 139 deletions

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# 0.13.0
1+
# 0.13.0-preview-1
22

3-
Released on Thursday, October 31 2019.
3+
Released on Sunday, November 3, 2019.
44

5-
- Initial release
5+
This is the initial preview release of AngleSharp.Diffing.

Directory.Build.props

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

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
![AngleSharp Diffing](/docs/header.png)
12
# AngleSharp Diffing - A diff/compare library for AngleSharp
23
[![Build status](https://ci.appveyor.com/api/projects/status/8awr3r4ylwy9habm?svg=true)](https://ci.appveyor.com/project/FlorianRappl/anglesharp-diffing)
4+
[![GitHub Tag](https://img.shields.io/github/tag/AngleSharp/AngleSharp.Diffing.svg?style=flat-square)](https://github.com/AngleSharp/AngleSharp.Diffing/releases)
5+
[![NuGet Count](https://img.shields.io/nuget/dt/AngleSharp.Diffing.svg?style=flat-square)](https://www.nuget.org/packages/AngleSharp.Diffing/)
6+
[![Issues Open](https://img.shields.io/github/issues/AngleSharp/AngleSharp.Diffing.svg?style=flat-square)](https://github.com/AngleSharp/AngleSharp.Diffing/issues)
7+
[![Gitter Chat](http://img.shields.io/badge/gitter-AngleSharp/AngleSharp-blue.svg?style=flat-square)](https://gitter.im/AngleSharp/AngleSharp)
8+
[![StackOverflow Questions](https://img.shields.io/stackexchange/stackoverflow/t/anglesharp.svg?style=flat-square)](https://stackoverflow.com/tags/anglesharp)
9+
[![CLA Assistant](https://cla-assistant.io/readme/badge/AngleSharp/AngleSharp.Diffing?style=flat-square)](https://cla-assistant.io/AngleSharp/AngleSharp.Diffing)
310

4-
This library makes it possible to compare a AngleSharp _control_ `INodeList` and a _test_ `INodeList` and get a list of `IDiff` differences between them.
11+
AngleSharp Diffing makes it possible to compare AngleSharp _control_ nodes and _test_ nodes and get a list of differences between them.
512

613
The _control_ nodes represents the expected HTML tree, i.e. how the nodes are expected to look, and the _test_ nodes represents the nodes that should be compared to the _control_ nodes.
714

815
**Differences:** There are three types off `IDiff` differences, that the library can return.
916

10-
- `Diff`/`AttrDiff`: Represents a difference between a control and test node or a control and test attribute.
11-
- `MissingDiff`/`MissingAttrDiff`: Represents a difference where a control node or control attribute was expected to exist, but was not found in the test nodes tree.
12-
- `UnexpectedDiff`/`UnexpectedAttrDiff`: Represents a difference where a test node or test attribute was unexpectedly found in the test nodes tree, but did not have a match in the control nodes tree.
17+
- `NodeDiff`/`AttrDiff`: Represents a difference between a control and test node or a control and test attribute.
18+
- `MissingNodeDiff`/`MissingAttrDiff`: Represents a difference where a control node or control attribute was expected to exist, but was not found in the test nodes tree.
19+
- `UnexpectedNodeDiff`/`UnexpectedAttrDiff`: Represents a difference where a test node or test attribute was unexpectedly found in the test nodes tree, but did not have a match in the control nodes tree.
1320

1421
# Usage
1522
To find the differences between a control HTML fragment and a test HTML fragment, using the default options, the easiest way is to use the `DiffBuilder` class, like so:

docs/header.png

13.3 KB
Loading

docs/logo.png

3.51 KB
Loading

src/AngleSharp.Diffing.Tests/Core/HtmlDifferenceEngineTest.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ public void WhenNodesAreDifferentADiffIsReturned()
109109
var results = sut.Compare(nodes, nodes).ToList();
110110

111111
results.Count.ShouldBe(3);
112-
results[0].ShouldBeOfType<Diff>().ShouldSatisfyAllConditions(
112+
results[0].ShouldBeOfType<NodeDiff>().ShouldSatisfyAllConditions(
113113
diff => diff.Control.Node.NodeName.ShouldBe("P"),
114114
diff => diff.Result.ShouldBe(DiffResult.Different),
115115
diff => diff.Target.ShouldBe(DiffTarget.Element)
116116
);
117-
results[1].ShouldBeOfType<Diff>().ShouldSatisfyAllConditions(
117+
results[1].ShouldBeOfType<NodeDiff>().ShouldSatisfyAllConditions(
118118
diff => diff.Control.Node.NodeName.ShouldBe("#comment"),
119119
diff => diff.Result.ShouldBe(DiffResult.Different),
120120
diff => diff.Target.ShouldBe(DiffTarget.Comment)
121121
);
122-
results[2].ShouldBeOfType<Diff>().ShouldSatisfyAllConditions(
122+
results[2].ShouldBeOfType<NodeDiff>().ShouldSatisfyAllConditions(
123123
diff => diff.Control.Node.NodeName.ShouldBe("#text"),
124124
diff => diff.Result.ShouldBe(DiffResult.Different),
125125
diff => diff.Target.ShouldBe(DiffTarget.Text)
@@ -274,11 +274,11 @@ public void WhenBothTestAndControlHaveChildNodesTheseAreCompared()
274274
var results = sut.Compare(nodes, nodes).ToList();
275275

276276
results.Count.ShouldBe(5);
277-
results[0].ShouldBeOfType<Diff>().Control.Node.NodeName.ShouldBe("MAIN");
278-
results[1].ShouldBeOfType<Diff>().Control.Node.NodeName.ShouldBe("H1");
279-
results[2].ShouldBeOfType<Diff>().Control.Node.NodeValue.ShouldBe("foobar");
280-
results[3].ShouldBeOfType<Diff>().Control.Node.NodeName.ShouldBe("P");
281-
results[4].ShouldBeOfType<Diff>().Control.Node.NodeName.ShouldBe("#text");
277+
results[0].ShouldBeOfType<NodeDiff>().Control.Node.NodeName.ShouldBe("MAIN");
278+
results[1].ShouldBeOfType<NodeDiff>().Control.Node.NodeName.ShouldBe("H1");
279+
results[2].ShouldBeOfType<NodeDiff>().Control.Node.NodeValue.ShouldBe("foobar");
280+
results[3].ShouldBeOfType<NodeDiff>().Control.Node.NodeName.ShouldBe("P");
281+
results[4].ShouldBeOfType<NodeDiff>().Control.Node.NodeName.ShouldBe("#text");
282282
}
283283

284284
[Theory(DisplayName = "When only one of the control or test node in a comparison has child nodes, a missing/unexpected diff is returned")]
@@ -294,7 +294,7 @@ public void OnlyOnePartHasChildNodes(string control, string test, Type expectedD
294294
var results = sut.Compare(ToNodeList(control), ToNodeList(test)).ToList();
295295

296296
results.Count.ShouldBe(2);
297-
results[0].ShouldBeOfType<Diff>();
297+
results[0].ShouldBeOfType<NodeDiff>();
298298
results[1].ShouldBeOfType(expectedDiffType);
299299
}
300300

@@ -312,14 +312,14 @@ public void PathIsSetCorrectly()
312312
var results = sut.Compare(ctrlNodes, testNodes).ToList();
313313

314314
results.Count.ShouldBe(4);
315-
results[0].ShouldBeOfType<Diff>().Control.Path.ShouldBe("main(0)");
316-
results[0].ShouldBeOfType<Diff>().Test.Path.ShouldBe("main(1)");
317-
results[1].ShouldBeOfType<Diff>().Control.Path.ShouldBe("main(0) > h1(0)");
318-
results[1].ShouldBeOfType<Diff>().Test.Path.ShouldBe("main(1) > h1(0)");
319-
results[2].ShouldBeOfType<Diff>().Control.Path.ShouldBe("main(0) > h1(0) > p(1)");
320-
results[2].ShouldBeOfType<Diff>().Test.Path.ShouldBe("main(1) > h1(0) > p(0)");
321-
results[3].ShouldBeOfType<Diff>().Control.Path.ShouldBe("main(0) > h1(0) > p(1) > #text(0)");
322-
results[3].ShouldBeOfType<Diff>().Test.Path.ShouldBe("main(1) > h1(0) > p(0) > #text(0)");
315+
results[0].ShouldBeOfType<NodeDiff>().Control.Path.ShouldBe("main(0)");
316+
results[0].ShouldBeOfType<NodeDiff>().Test.Path.ShouldBe("main(1)");
317+
results[1].ShouldBeOfType<NodeDiff>().Control.Path.ShouldBe("main(0) > h1(0)");
318+
results[1].ShouldBeOfType<NodeDiff>().Test.Path.ShouldBe("main(1) > h1(0)");
319+
results[2].ShouldBeOfType<NodeDiff>().Control.Path.ShouldBe("main(0) > h1(0) > p(1)");
320+
results[2].ShouldBeOfType<NodeDiff>().Test.Path.ShouldBe("main(1) > h1(0) > p(0)");
321+
results[3].ShouldBeOfType<NodeDiff>().Control.Path.ShouldBe("main(0) > h1(0) > p(1) > #text(0)");
322+
results[3].ShouldBeOfType<NodeDiff>().Test.Path.ShouldBe("main(1) > h1(0) > p(0) > #text(0)");
323323
}
324324

325325
[Fact(DisplayName = "Attribute path in comparison sources are based on nodes tree structure")]
@@ -339,6 +339,7 @@ public void AttributeSourcePathisBasedOnParentElements()
339339

340340
results.Count.ShouldBe(1);
341341
results[0].ShouldBeOfType<AttrDiff>().Control.Path.ShouldBe("p(0)[id]");
342+
results[0].ShouldBeOfType<AttrDiff>().Test.Path.ShouldBe("p(0)[id]");
342343
}
343344

344345
[Fact(DisplayName = "Comparison sources have their type set correctly")]
@@ -358,8 +359,8 @@ public void ComparisonSourcesHaveCorrectType()
358359

359360
results.Count.ShouldBe(2);
360361

361-
results[0].ShouldBeOfType<Diff>().Control.SourceType.ShouldBe(ComparisonSourceType.Control);
362-
results[0].ShouldBeOfType<Diff>().Test.SourceType.ShouldBe(ComparisonSourceType.Test);
362+
results[0].ShouldBeOfType<NodeDiff>().Control.SourceType.ShouldBe(ComparisonSourceType.Control);
363+
results[0].ShouldBeOfType<NodeDiff>().Test.SourceType.ShouldBe(ComparisonSourceType.Test);
363364
results[1].ShouldBeOfType<AttrDiff>().Control.SourceType.ShouldBe(ComparisonSourceType.Control);
364365
results[1].ShouldBeOfType<AttrDiff>().Test.SourceType.ShouldBe(ComparisonSourceType.Test);
365366
}

src/AngleSharp.Diffing.Tests/DiffBuilderTest.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,22 @@ public void Test002()
3434
[Fact(DisplayName = "Calling Build() with DefaultOptions() returns expected diffs")]
3535
public void Test003()
3636
{
37-
var control = "<p>hello <em>world</em></p>";
38-
var test = "<p>world says <strong>hello</strong></p>";
37+
var control = @"<p attr=""foo"" missing>hello <em>world</em></p>";
38+
var test = @"<p attr=""bar"" unexpected>world says <strong>hello</strong></p>";
3939

4040
var diffs = DiffBuilder
4141
.Compare(control)
4242
.WithTest(test)
43-
.Build();
43+
.Build()
44+
.ToList();
4445

45-
diffs.Count().ShouldBe(3);
46+
diffs.Count.ShouldBe(6);
47+
diffs.SingleOrDefault(x => x is AttrDiff).ShouldNotBeNull();
48+
diffs.SingleOrDefault(x => x is MissingAttrDiff).ShouldNotBeNull();
49+
diffs.SingleOrDefault(x => x is UnexpectedAttrDiff).ShouldNotBeNull();
50+
diffs.SingleOrDefault(x => x is NodeDiff).ShouldNotBeNull();
51+
diffs.SingleOrDefault(x => x is MissingNodeDiff).ShouldNotBeNull();
52+
diffs.SingleOrDefault(x => x is UnexpectedNodeDiff).ShouldNotBeNull();
4653
}
4754

4855
[Fact(DisplayName = "Setting options works")]

src/AngleSharp.Diffing.nuspec

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

src/AngleSharp.Diffing.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{166F21F6-7
2222
..\CHANGELOG.md = ..\CHANGELOG.md
2323
..\docs\CustomOptions.md = ..\docs\CustomOptions.md
2424
..\docs\DiffingEngineInternals.md = ..\docs\DiffingEngineInternals.md
25+
..\docs\header.png = ..\docs\header.png
26+
..\docs\logo.png = ..\docs\logo.png
2527
..\docs\Options.md = ..\docs\Options.md
2628
..\README.md = ..\README.md
2729
EndProjectSection
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
</PropertyGroup>
66

77
<PropertyGroup Condition="'$(Configuration)'=='Release'">
8-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
</PropertyGroup>
1010

1111
<PropertyGroup>
12+
<Description>Provides a complete diffing model of HTML.</Description>
13+
<Product>AngleSharp.Diffing</Product>
14+
<Authors>AngleSharp</Authors>
15+
<PackageId>AngleSharp.Diffing</PackageId>
16+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
17+
<PackageProjectUrl>https://anglesharp.github.io</PackageProjectUrl>
18+
<PackageIcon>logo.png</PackageIcon>
19+
<PackageIconUrl>https://raw.github.com/AngleSharp/AngleSharp.Diffing/master/docs/logo.png</PackageIconUrl>
20+
<PackageTags>html html5 css css3 dom library diffing anglesharp diff difference compare comparison testing</PackageTags>
21+
<Copyright>Copyright 2019, Egil Hansen</Copyright>
22+
<RepositoryUrl>https://github.com/egil/razor-components-testing-library</RepositoryUrl>
23+
<RepositoryType>git</RepositoryType>
1224
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1325
<IncludeSymbols>true</IncludeSymbols>
1426
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1527
</PropertyGroup>
16-
28+
1729
<ItemGroup>
18-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19351-01" PrivateAssets="All"/>
30+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
1931
</ItemGroup>
20-
32+
2133
<ItemGroup>
2234
<PackageReference Include="AngleSharp" Version="$(AngleSharpVersion)" />
2335
<PackageReference Include="AngleSharp.Css" Version="$(AngleSharpVersion)" />
@@ -27,4 +39,9 @@
2739
</PackageReference>
2840
</ItemGroup>
2941

42+
<ItemGroup>
43+
<None Include="..\..\docs\logo.png" Pack="true" PackagePath="\"/>
44+
<None Include="..\..\LICENSE" Pack="true" PackagePath="\"/>
45+
</ItemGroup>
46+
3047
</Project>

0 commit comments

Comments
 (0)