41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
|
using NUnit.Framework;
|
||
|
|
||
|
namespace ln.type.tests
|
||
|
{
|
||
|
public class URITests
|
||
|
{
|
||
|
[SetUp]
|
||
|
public void Setup()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Test1()
|
||
|
{
|
||
|
string testBaseURI = "http://alpha:beta:gamma@myHost:3456/path/to/resource?query=all#fragmentA";
|
||
|
|
||
|
URI testURI = new URI(testBaseURI);
|
||
|
Assert.AreEqual(testBaseURI, testURI.ToString(true));
|
||
|
|
||
|
Assert.AreEqual(
|
||
|
"http://omega@myHost:3456/path/to/resource?query=all#fragmentA",
|
||
|
testURI.WithUserInfo("omega").ToString(true)
|
||
|
);
|
||
|
Assert.AreEqual(
|
||
|
"http://alpha:beta:gamma@myHost:3456/my/path?query=all#fragmentA",
|
||
|
testURI.WithPath("/my/path").ToString(true)
|
||
|
);
|
||
|
Assert.AreEqual(
|
||
|
"http://alpha:beta:gamma@myHost:3456/path/to/resource?such=a&shame#fragmentA",
|
||
|
testURI.WithQuery("such=a&shame").ToString(true)
|
||
|
);
|
||
|
Assert.AreEqual(
|
||
|
"https://alpha:beta:gamma@myHost:3456/path/to/resource?query=all#fragmentA",
|
||
|
testURI.WithScheme("https").ToString(true)
|
||
|
);
|
||
|
|
||
|
|
||
|
Assert.Pass();
|
||
|
}
|
||
|
}
|
||
|
}
|