Skip to content

Commit 99141c8

Browse files
committed
add tests
1 parent 41c20c9 commit 99141c8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace FeatBit.Sdk.Server;
2+
3+
public class UriTests
4+
{
5+
// According to the documentation: https://learn.microsoft.com/en-us/dotnet/api/system.uri.-ctor?view=net-6.0#system-uri-ctor(system-uri-system-string)
6+
// if the relative part of baseUri is to be preserved in the constructed Uri,
7+
// the baseUri has relative parts (like /api), then the relative part must be terminated with a slash, (like /api/)
8+
[Theory]
9+
[InlineData("https://contoso.com/featbit/", "relative", "https://contoso.com/featbit/relative")]
10+
[InlineData("https://contoso.com/featbit/", "relative?type=server", "https://contoso.com/featbit/relative?type=server")]
11+
[InlineData("https://contoso.com", "relative", "https://contoso.com/relative")]
12+
[InlineData("https://contoso.com", "/relative", "https://contoso.com/relative")]
13+
[InlineData("https://contoso.com/", "/relative", "https://contoso.com/relative")]
14+
public void CreateUri(string @base, string relative, string expected)
15+
{
16+
var baseUri = new Uri(@base);
17+
var uri = new Uri(baseUri, relative);
18+
19+
Assert.Equal(expected, uri.ToString());
20+
}
21+
}

0 commit comments

Comments
 (0)