Unit tests for suggested URIs
This commit is contained in:
parent
dafd0e31ff
commit
885b1b8029
2 changed files with 47 additions and 1 deletions
46
LANCommander.SDK.Tests/UriExtensions.cs
Normal file
46
LANCommander.SDK.Tests/UriExtensions.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using LANCommander.SDK.Extensions;
|
||||
|
||||
namespace LANCommander.SDK.Tests;
|
||||
|
||||
public class UriExtensions
|
||||
{
|
||||
[Fact]
|
||||
public void ValidUriShouldIncludeKnownPorts()
|
||||
{
|
||||
var input = "http://localhost:5000";
|
||||
|
||||
var uris = input.SuggestValidUris();
|
||||
var strings = uris.Select(u => u.ToString()).ToList();
|
||||
|
||||
Assert.Equal(10, strings.Count);
|
||||
Assert.Contains("http://localhost:5000/", strings);
|
||||
Assert.Contains("https://localhost:5000/", strings);
|
||||
Assert.Contains("http://localhost/", strings);
|
||||
Assert.Contains("http://localhost:443/", strings);
|
||||
Assert.Contains("https://localhost/", strings);
|
||||
Assert.Contains("https://localhost:80/", strings);
|
||||
Assert.Contains("http://localhost:1337/", strings);
|
||||
Assert.Contains("https://localhost:1337/", strings);
|
||||
Assert.Contains("http://localhost:31337/", strings);
|
||||
Assert.Contains("https://localhost:31337/", strings);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidIpAddressShouldReturnValidUris()
|
||||
{
|
||||
var input = "10.0.1.10";
|
||||
|
||||
var uris = input.SuggestValidUris();
|
||||
var strings = uris.Select(u => u.ToString()).ToList();
|
||||
|
||||
Assert.Equal(8, strings.Count);
|
||||
Assert.Contains("http://10.0.1.10:1337/", strings);
|
||||
Assert.Contains("https://10.0.1.10:1337/", strings);
|
||||
Assert.Contains("http://10.0.1.10/", strings);
|
||||
Assert.Contains("http://10.0.1.10:443/", strings);
|
||||
Assert.Contains("https://10.0.1.10/", strings);
|
||||
Assert.Contains("https://10.0.1.10:80/", strings);
|
||||
Assert.Contains("http://10.0.1.10:31337/", strings);
|
||||
Assert.Contains("https://10.0.1.10:31337/", strings);
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ public static class UriExtensions
|
|||
Scheme = Uri.UriSchemeHttp,
|
||||
Port = uri.Port,
|
||||
}.Uri);
|
||||
else if (uri.Scheme == Uri.UriSchemeHttps)
|
||||
else if (uri.Scheme != Uri.UriSchemeHttps)
|
||||
uris.Add(new UriBuilder(url)
|
||||
{
|
||||
Scheme = Uri.UriSchemeHttps,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue