-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from AngleSharp/devel
v.0.18.1
- Loading branch information
Showing
115 changed files
with
5,233 additions
and
5,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 66 additions & 73 deletions
139
src/AngleSharp.Diffing.Tests/Core/AttributeComparisonSourceTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,82 @@ | ||
using System; | ||
namespace AngleSharp.Diffing.Core; | ||
|
||
using Shouldly; | ||
|
||
using Xunit; | ||
|
||
namespace AngleSharp.Diffing.Core | ||
public class AttributeComparisonSourceTest : DiffingTestBase | ||
{ | ||
public class AttributeComparisonSourceTest : DiffingTestBase | ||
public AttributeComparisonSourceTest(DiffingTestFixture fixture) : base(fixture) | ||
{ | ||
public AttributeComparisonSourceTest(DiffingTestFixture fixture) : base(fixture) | ||
{ | ||
} | ||
|
||
[Fact(DisplayName = "When a null is used for element source, an exception is thrown")] | ||
public void Test003() | ||
{ | ||
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource(null!, new ComparisonSource())); | ||
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource("", new ComparisonSource())); | ||
} | ||
|
||
[Fact(DisplayName = "When a element source does not contain the specified attribute name, an exception is thrown")] | ||
public void Test004() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br>", ComparisonSourceType.Control); | ||
} | ||
|
||
Should.Throw<ArgumentException>(() => new AttributeComparisonSource("notFoundAttr", elementSource)); | ||
} | ||
[Fact(DisplayName = "When a null is used for element source, an exception is thrown")] | ||
public void Test003() | ||
{ | ||
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource(null!, new ComparisonSource())); | ||
Should.Throw<ArgumentNullException>(() => new AttributeComparisonSource("", new ComparisonSource())); | ||
} | ||
|
||
[Fact(DisplayName = "Two sources are equal if all their properties are equal")] | ||
public void Test1() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("foo", elementSource); | ||
[Fact(DisplayName = "When a element source does not contain the specified attribute name, an exception is thrown")] | ||
public void Test004() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br>", ComparisonSourceType.Control); | ||
|
||
source.Equals(otherSource).ShouldBeTrue(); | ||
source.Equals((object)otherSource).ShouldBeTrue(); | ||
(source == otherSource).ShouldBeTrue(); | ||
(source != otherSource).ShouldBeFalse(); | ||
} | ||
Should.Throw<ArgumentException>(() => new AttributeComparisonSource("notFoundAttr", elementSource)); | ||
} | ||
|
||
[Fact(DisplayName = "Two sources are not equal if their attribute is different")] | ||
public void Test11() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("bar", elementSource); | ||
[Fact(DisplayName = "Two sources are equal if all their properties are equal")] | ||
public void Test1() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("foo", elementSource); | ||
|
||
source.Equals(otherSource).ShouldBeTrue(); | ||
source.Equals((object)otherSource).ShouldBeTrue(); | ||
(source == otherSource).ShouldBeTrue(); | ||
(source != otherSource).ShouldBeFalse(); | ||
} | ||
|
||
source.Equals(otherSource).ShouldBeFalse(); | ||
(source == otherSource).ShouldBeFalse(); | ||
(source != otherSource).ShouldBeTrue(); | ||
} | ||
[Fact(DisplayName = "Two sources are not equal if their attribute is different")] | ||
public void Test11() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("bar", elementSource); | ||
|
||
[Fact(DisplayName = "Two sources are not equal if their element source is different")] | ||
public void Test3() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("bar", otherElementSource); | ||
source.Equals(otherSource).ShouldBeFalse(); | ||
(source == otherSource).ShouldBeFalse(); | ||
(source != otherSource).ShouldBeTrue(); | ||
} | ||
|
||
source.Equals(otherSource).ShouldBeFalse(); | ||
(source == otherSource).ShouldBeFalse(); | ||
(source != otherSource).ShouldBeTrue(); | ||
} | ||
[Fact(DisplayName = "Two sources are not equal if their element source is different")] | ||
public void Test3() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("bar", otherElementSource); | ||
|
||
source.Equals(otherSource).ShouldBeFalse(); | ||
(source == otherSource).ShouldBeFalse(); | ||
(source != otherSource).ShouldBeTrue(); | ||
} | ||
|
||
[Fact(DisplayName = "GetHashCode correctly returns same value for two equal sources")] | ||
public void Test001() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("foo", elementSource); | ||
[Fact(DisplayName = "GetHashCode correctly returns same value for two equal sources")] | ||
public void Test001() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("foo", elementSource); | ||
|
||
source.GetHashCode().ShouldBe(otherSource.GetHashCode()); | ||
} | ||
source.GetHashCode().ShouldBe(otherSource.GetHashCode()); | ||
} | ||
|
||
[Fact(DisplayName = "GetHashCode correctly returns different values for two unequal sources")] | ||
public void Test002() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("bar", otherElementSource); | ||
[Fact(DisplayName = "GetHashCode correctly returns different values for two unequal sources")] | ||
public void Test002() | ||
{ | ||
var elementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var otherElementSource = ToComparisonSource(@"<br foo=""bar"" bar=""baz"">", ComparisonSourceType.Control); | ||
var source = new AttributeComparisonSource("foo", elementSource); | ||
var otherSource = new AttributeComparisonSource("bar", otherElementSource); | ||
|
||
source.GetHashCode().ShouldNotBe(otherSource.GetHashCode()); | ||
} | ||
source.GetHashCode().ShouldNotBe(otherSource.GetHashCode()); | ||
} | ||
} |
Oops, something went wrong.