-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29e9264
commit d228287
Showing
2 changed files
with
38 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,25 @@ namespace LinkValidator.Tests; | |
|
||
public class UriHelperSpecs | ||
{ | ||
public static readonly TheoryData<AbsoluteUri, string, bool> CanMakeAbsoluteUriData = new() | ||
{ | ||
{ new AbsoluteUri(new Uri("http://example.com")), "http://example.com/some/path", true }, | ||
{ new AbsoluteUri(new Uri("http://example.com")), "https://example.com/some/path", true }, | ||
{ new AbsoluteUri(new Uri("http://example.com")), "/some/path", true }, | ||
{ new AbsoluteUri(new Uri("http://example.com")), "mailto:[email protected]", false } | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(CanMakeAbsoluteUriData))] | ||
public void CanMakeAbsoluteUri_should_return_expected_results(AbsoluteUri baseUri, string rawUri, bool expected) | ||
{ | ||
// Act | ||
var result = UriHelpers.CanMakeAbsoluteHttpUri(baseUri, rawUri); | ||
|
||
// Assert | ||
result.Should().Be(expected); | ||
} | ||
|
||
[Theory] | ||
[InlineData("http://example.com", "http://example.com/some/path")] | ||
[InlineData("https://example.com", "http://example.com/some/path")] | ||
|
@@ -39,6 +58,22 @@ public void AbsoluteUriIsInDomain_should_NOT_return_true_when_host_is_diffrent(s | |
// Assert | ||
result.Should().BeFalse(); | ||
} | ||
|
||
|
||
public static readonly TheoryData<AbsoluteUri, string, AbsoluteUri> ToAbsoluteUriData = new() | ||
{ | ||
{ new AbsoluteUri(new Uri("http://example.com")), "http://example.com/some/path", new AbsoluteUri(new Uri("http://example.com/some/path")) }, | ||
{ new AbsoluteUri(new Uri("http://example.com")), "/some/path", new AbsoluteUri(new Uri("http://example.com/some/path")) }, | ||
{ new AbsoluteUri(new Uri("http://example.com")), "some/path", new AbsoluteUri(new Uri("http://example.com/some/path")) } | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(ToAbsoluteUriData))] | ||
public void ToAbsoluteUri_should_return_expected_results(AbsoluteUri baseUri, string rawUri, AbsoluteUri expected) | ||
{ | ||
// Act | ||
var result = UriHelpers.ToAbsoluteUri(baseUri, rawUri); | ||
|
||
// Assert | ||
result.Should().Be(expected); | ||
} | ||
} |
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