mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
fix: Fixing bug where IcdUriBuilder was not correctly appending paths
This commit is contained in:
@@ -16,43 +16,43 @@ namespace ICD.Common.Utils.Tests
|
|||||||
[TestCase("test")]
|
[TestCase("test")]
|
||||||
public void HostTest(string host)
|
public void HostTest(string host)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(host, new IcdUriBuilder { Host = host }.Host);
|
Assert.AreEqual(host, new IcdUriBuilder {Host = host}.Host);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("test")]
|
[TestCase("test")]
|
||||||
public void PasswordTest(string fragment)
|
public void PasswordTest(string fragment)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(fragment, new IcdUriBuilder { Password = fragment }.Password);
|
Assert.AreEqual(fragment, new IcdUriBuilder {Password = fragment}.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("test")]
|
[TestCase("test")]
|
||||||
public void PathTest(string fragment)
|
public void PathTest(string fragment)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(fragment, new IcdUriBuilder { Path = fragment }.Path);
|
Assert.AreEqual(fragment, new IcdUriBuilder {Path = fragment}.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase((ushort)80)]
|
[TestCase((ushort)80)]
|
||||||
public void PortTest(ushort port)
|
public void PortTest(ushort port)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(port, new IcdUriBuilder { Port = port }.Port);
|
Assert.AreEqual(port, new IcdUriBuilder {Port = port}.Port);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("test")]
|
[TestCase("test")]
|
||||||
public void QueryTest(string query)
|
public void QueryTest(string query)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(query, new IcdUriBuilder { Query = query }.Query);
|
Assert.AreEqual(query, new IcdUriBuilder {Query = query}.Query);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("test")]
|
[TestCase("test")]
|
||||||
public void SchemeTest(string scheme)
|
public void SchemeTest(string scheme)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(scheme, new IcdUriBuilder { Scheme = scheme }.Scheme);
|
Assert.AreEqual(scheme, new IcdUriBuilder {Scheme = scheme}.Scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("test")]
|
[TestCase("test")]
|
||||||
public void UserNameTest(string userName)
|
public void UserNameTest(string userName)
|
||||||
{
|
{
|
||||||
Assert.AreEqual(userName, new IcdUriBuilder { UserName = userName }.UserName);
|
Assert.AreEqual(userName, new IcdUriBuilder {UserName = userName}.UserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -63,19 +63,23 @@ namespace ICD.Common.Utils.Tests
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[TestCase("http://localhost/", null, null, null, (ushort)0, null, null, null)]
|
[TestCase("http://localhost/", null, null, null, null, (ushort)0, null, null, null)]
|
||||||
[TestCase("http://localhost:80/", null, null, null, (ushort)80, null, null, null)]
|
[TestCase("http://localhost:80/", null, null, null, null, (ushort)80, null, null, null)]
|
||||||
[TestCase("http://username@localhost/", null, null, null, (ushort)0, null, null, "username")]
|
[TestCase("http://username@localhost/", null, null, null, null, (ushort)0, null, null, "username")]
|
||||||
[TestCase("http://localhost/", null, null, "password", (ushort)0, null, null, null)]
|
[TestCase("http://localhost/", null, null, "password", null, (ushort)0, null, null, null)]
|
||||||
[TestCase("https://localhost/", null, null, null, (ushort)0, null, "https", null)]
|
[TestCase("https://localhost/", null, null, null, null, (ushort)0, null, "https", null)]
|
||||||
public void ToStringTest(string expected, string fragment, string address, string password, ushort port, string query,
|
[TestCase("http://localhost/test", null, null, null, "test", (ushort)0, null, null, null)]
|
||||||
string scheme, string userName)
|
[TestCase("http://localhost/test", null, null, null, "/test", (ushort)0, null, null, null)]
|
||||||
|
[TestCase("http://localhost//test", null, null, null, "//test", (ushort)0, null, null, null)]
|
||||||
|
public void ToStringTest(string expected, string fragment, string address, string password, string path, ushort port,
|
||||||
|
string query, string scheme, string userName)
|
||||||
{
|
{
|
||||||
IcdUriBuilder builder = new IcdUriBuilder
|
IcdUriBuilder builder = new IcdUriBuilder
|
||||||
{
|
{
|
||||||
Fragment = fragment,
|
Fragment = fragment,
|
||||||
Host = address,
|
Host = address,
|
||||||
Password = password,
|
Password = password,
|
||||||
|
Path = path,
|
||||||
Port = port,
|
Port = port,
|
||||||
Query = query,
|
Query = query,
|
||||||
Scheme = scheme,
|
Scheme = scheme,
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ namespace ICD.Common.Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Path
|
// Path
|
||||||
builder.Append('/');
|
if (string.IsNullOrEmpty(Path) || !Path.StartsWith("/"))
|
||||||
|
builder.Append('/');
|
||||||
builder.Append(Path);
|
builder.Append(Path);
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
|||||||
Reference in New Issue
Block a user