Skip to content

Commit c672a03

Browse files
committed
update tests
1 parent d252601 commit c672a03

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/FluentRest/UrlBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ private void WritePath(StringBuilder builder)
587587
if (builder.Length > start)
588588
builder.Append('/');
589589

590-
var v = Uri.EscapeDataString(p);
590+
var v = Uri.EscapeDataString(p ?? string.Empty);
591591

592592
builder.Append(v);
593593
}

test/FluentRest.Tests/UrlBuilderTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,26 @@ public void BuildBasePath()
204204
builder.ToString().Should().Be("http://foo.com/test/bar?test=True");
205205

206206
}
207+
208+
[Fact]
209+
public void BuildBaseRelativePath()
210+
{
211+
var builder = UrlBuilder
212+
.Create("/foo")
213+
.AppendPath("/bar")
214+
.AppendQuery("test", true);
215+
216+
builder.Scheme.Should().BeEmpty();
217+
builder.Host.Should().BeEmpty();
218+
builder.Port.Should().BeNull();
219+
220+
builder.Path.Should().NotBeEmpty();
221+
builder.Path.Should().Contain("foo");
222+
builder.Path.Should().Contain("bar");
223+
224+
builder.Query.AllKeys.Length.Should().BeGreaterThan(0);
225+
builder.Query.AllKeys.Should().Contain("test");
226+
227+
builder.ToString().Should().Be("/foo/bar?test=True");
228+
}
207229
}

0 commit comments

Comments
 (0)