Skip to content

Commit e514267

Browse files
authored
Merge pull request #37 from AngleSharp/devel
v.0.18.1
2 parents aa349ad + 38875ff commit e514267

File tree

115 files changed

+5233
-5777
lines changed

Some content is hidden

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

115 files changed

+5233
-5777
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.18.1
2+
3+
- Fixed element comparer such that it can strictly check if the closing tags in the source markup is the same.
4+
15
# 0.18.0
26

37
- Added a new comparer, which ensures element tags are closed the same way, e.g. `<br> and <br />` would not be considered equal, but `<br>` and `<br>` would be.

src/AngleSharp.Diffing.Tests/AngleSharp.DiffingTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<AssemblyName>AngleSharp.Diffing.Tests</AssemblyName>
77
<RootNamespace>AngleSharp.Diffing</RootNamespace>
88
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5 -->
9-
<Nullable>annotations</Nullable>
9+
<Nullable>annotations</Nullable>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,82 @@
1-
using System;
1+
namespace AngleSharp.Diffing.Core;
22

3-
using Shouldly;
4-
5-
using Xunit;
6-
7-
namespace AngleSharp.Diffing.Core
3+
public class AttributeComparisonSourceTest : DiffingTestBase
84
{
9-
public class AttributeComparisonSourceTest : DiffingTestBase
5+
public AttributeComparisonSourceTest(DiffingTestFixture fixture) : base(fixture)
106
{
11-
public AttributeComparisonSourceTest(DiffingTestFixture fixture) : base(fixture)
12-
{
13-
}
14-
15-
[Fact(DisplayName = "When a null is used for element source, an exception is thrown")]
16-
public void Test003()
17-
{
18-
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource(null!, new ComparisonSource()));
19-
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource("", new ComparisonSource()));
20-
}
21-
22-
[Fact(DisplayName = "When a element source does not contain the specified attribute name, an exception is thrown")]
23-
public void Test004()
24-
{
25-
var elementSource = ToComparisonSource(@"<br>", ComparisonSourceType.Control);
7+
}
268

27-
Should.Throw<ArgumentException>(() => new AttributeComparisonSource("notFoundAttr", elementSource));
28-
}
9+
[Fact(DisplayName = "When a null is used for element source, an exception is thrown")]
10+
public void Test003()
11+
{
12+
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource(null!, new ComparisonSource()));
13+
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource("", new ComparisonSource()));
14+
}
2915

30-
[Fact(DisplayName = "Two sources are equal if all their properties are equal")]
31-
public void Test1()
32-
{
33-
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control);
34-
var source = new AttributeComparisonSource("foo", elementSource);
35-
var otherSource = new AttributeComparisonSource("foo", elementSource);
16+
[Fact(DisplayName = "When a element source does not contain the specified attribute name, an exception is thrown")]
17+
public void Test004()
18+
{
19+
var elementSource = ToComparisonSource(@"<br>", ComparisonSourceType.Control);
3620

37-
source.Equals(otherSource).ShouldBeTrue();
38-
source.Equals((object)otherSource).ShouldBeTrue();
39-
(source == otherSource).ShouldBeTrue();
40-
(source != otherSource).ShouldBeFalse();
41-
}
21+
Should.Throw<ArgumentException>(() => new AttributeComparisonSource("notFoundAttr", elementSource));
22+
}
4223

43-
[Fact(DisplayName = "Two sources are not equal if their attribute is different")]
44-
public void Test11()
45-
{
46-
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
47-
var source = new AttributeComparisonSource("foo", elementSource);
48-
var otherSource = new AttributeComparisonSource("bar", elementSource);
24+
[Fact(DisplayName = "Two sources are equal if all their properties are equal")]
25+
public void Test1()
26+
{
27+
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control);
28+
var source = new AttributeComparisonSource("foo", elementSource);
29+
var otherSource = new AttributeComparisonSource("foo", elementSource);
30+
31+
source.Equals(otherSource).ShouldBeTrue();
32+
source.Equals((object)otherSource).ShouldBeTrue();
33+
(source == otherSource).ShouldBeTrue();
34+
(source != otherSource).ShouldBeFalse();
35+
}
4936

50-
source.Equals(otherSource).ShouldBeFalse();
51-
(source == otherSource).ShouldBeFalse();
52-
(source != otherSource).ShouldBeTrue();
53-
}
37+
[Fact(DisplayName = "Two sources are not equal if their attribute is different")]
38+
public void Test11()
39+
{
40+
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
41+
var source = new AttributeComparisonSource("foo", elementSource);
42+
var otherSource = new AttributeComparisonSource("bar", elementSource);
5443

55-
[Fact(DisplayName = "Two sources are not equal if their element source is different")]
56-
public void Test3()
57-
{
58-
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
59-
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
60-
var source = new AttributeComparisonSource("foo", elementSource);
61-
var otherSource = new AttributeComparisonSource("bar", otherElementSource);
44+
source.Equals(otherSource).ShouldBeFalse();
45+
(source == otherSource).ShouldBeFalse();
46+
(source != otherSource).ShouldBeTrue();
47+
}
6248

63-
source.Equals(otherSource).ShouldBeFalse();
64-
(source == otherSource).ShouldBeFalse();
65-
(source != otherSource).ShouldBeTrue();
66-
}
49+
[Fact(DisplayName = "Two sources are not equal if their element source is different")]
50+
public void Test3()
51+
{
52+
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
53+
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
54+
var source = new AttributeComparisonSource("foo", elementSource);
55+
var otherSource = new AttributeComparisonSource("bar", otherElementSource);
56+
57+
source.Equals(otherSource).ShouldBeFalse();
58+
(source == otherSource).ShouldBeFalse();
59+
(source != otherSource).ShouldBeTrue();
60+
}
6761

68-
[Fact(DisplayName = "GetHashCode correctly returns same value for two equal sources")]
69-
public void Test001()
70-
{
71-
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control);
72-
var source = new AttributeComparisonSource("foo", elementSource);
73-
var otherSource = new AttributeComparisonSource("foo", elementSource);
62+
[Fact(DisplayName = "GetHashCode correctly returns same value for two equal sources")]
63+
public void Test001()
64+
{
65+
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control);
66+
var source = new AttributeComparisonSource("foo", elementSource);
67+
var otherSource = new AttributeComparisonSource("foo", elementSource);
7468

75-
source.GetHashCode().ShouldBe(otherSource.GetHashCode());
76-
}
69+
source.GetHashCode().ShouldBe(otherSource.GetHashCode());
70+
}
7771

78-
[Fact(DisplayName = "GetHashCode correctly returns different values for two unequal sources")]
79-
public void Test002()
80-
{
81-
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
82-
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
83-
var source = new AttributeComparisonSource("foo", elementSource);
84-
var otherSource = new AttributeComparisonSource("bar", otherElementSource);
72+
[Fact(DisplayName = "GetHashCode correctly returns different values for two unequal sources")]
73+
public void Test002()
74+
{
75+
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
76+
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control);
77+
var source = new AttributeComparisonSource("foo", elementSource);
78+
var otherSource = new AttributeComparisonSource("bar", otherElementSource);
8579

86-
source.GetHashCode().ShouldNotBe(otherSource.GetHashCode());
87-
}
80+
source.GetHashCode().ShouldNotBe(otherSource.GetHashCode());
8881
}
8982
}

0 commit comments

Comments
 (0)