public void WithFragment_ShouldSetPreExistingFragment() { var result = FluentUriBuilder.New("http://host:1234/test#frag") .Build().ToString(); Assert.Equal("http://host:1234/test#frag", result); }
public void WithHost_ShouldUpdateHost() { var result = FluentUriBuilder.New("http://host:1234/test") .WithHost("newhost").Build(); Assert.Equal(new Uri("http://newhost:1234/test"), result); }
public void New_ShouldBuildBasicUriFromStringInput() { var result = FluentUriBuilder.New("http://thehost").Build(); Assert.Equal("thehost", result.Host); Assert.Equal("http", result.Scheme); }
public void New_ShouldBuildUriFromStringInputWithPath() { var result = FluentUriBuilder.New("http://thehost/thepath").Build(); Assert.Equal("thehost", result.Host); Assert.Equal("http", result.Scheme); Assert.Equal("http://thehost/thepath", result.ToString()); }
public void New_ShouldBuildUriFromStringInputWithPathAndPortAndQueryString() { var result = FluentUriBuilder.New("http://thehost:8945/thepath?id=54").Build(); Assert.Equal("thehost", result.Host); Assert.Equal("http", result.Scheme); Assert.Equal("http://thehost:8945/thepath?id=54", result.ToString()); }
public void WithPath_ShouldAddPathToUriWithPath() { var result = FluentUriBuilder.New("http://host") .WithPath("mypath/hello") .Build(); Assert.Equal("/mypath/hello", result.AbsolutePath); }
public void WithScheme_ShouldChangeScheme() { var result = FluentUriBuilder.New("http://host") .WithScheme("test") .Build(); Assert.Equal("test", result.Scheme); }
public void AddQuery_ShouldAddQueryParameter() { var result = FluentUriBuilder.New("http://host:1234/test") .AddQuery("myparam", "myvalue") .Build().ToString(); Assert.Equal("http://host:1234/test?myparam=myvalue", result); }
public void WithPathSegment_ShouldSetSegmentForTemplate() { var result = FluentUriBuilder.New("http://host:1234/{seg1}") .WithSegment("seg1", "segmentone") .Build(); Assert.Equal("http://host:1234/segmentone", result.ToString()); }
public void WithPort_ShouldSetPort() { var result = FluentUriBuilder.New("http://host/path") .WithPort(1234) .Build(); Assert.Equal(1234, result.Port); Assert.Equal("http://host:1234/path", result.ToString()); }
public void AddPathTemplate_ShouldHandleSlashesCorrectlyWhenTemplateBeginsWithSlash() { var result = FluentUriBuilder.New("http://host:1234/test") .AddPathTemplate("/{test}/whatever/{test2}") .WithSegment("test", "karl") .WithSegment("test2", "karl2") .Build(); Assert.Equal(new Uri("http://host:1234/test/karl/whatever/karl2"), result); }
public void WithPathTemplate_ShouldAddTemplateToPath() { var result = FluentUriBuilder.New("http://host:1234/{seg1}") .WithSegment("seg1", "segone") .AddPathTemplate("{newseg}/someseg") .WithSegment("newseg", "test") .Build(); Assert.Equal("http://host:1234/segone/test/someseg", result.ToString()); }
public void Explore() { var result = FluentUriBuilder.New("http://host:1234/test") .AddPathTemplate("/{test}/whatever/{test2}") .WithSegment("test", "karl") .WithSegment("test2", "karl2") .Build(); Assert.Equal(new Uri("http://host:1234/test/karl/whatever/karl2"), result); }
public void WithQueries_ShouldAddMultipleQueryParamerters2() { var result = FluentUriBuilder.New("http://host:1234/test") .AddQueries(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("what", "hey"), new KeyValuePair <string, string>("no", "yes") }) .Build(); Assert.Equal(new Uri("http://host:1234/test?what=hey&no=yes"), result); }
public void Host_CannotPassNullAsUriString() { try { FluentUriBuilder.New("http://test").WithHost(null); } catch (Exception e) { Assert.Equal("ContractException", e.GetType().Name); } }
public void WithFragment_ShouldThrowIfGivenEmptyString() { Assert.Throws <ArgumentException>(() => FluentUriBuilder.New("http://host:1234/test") .WithFragment(string.Empty)); }
public void AddPathTemplate_ShouldThrowIfGivenEmptyString() { Assert.Throws <ArgumentException>(() => FluentUriBuilder.New("http://host:1234/test") .AddPathTemplate(string.Empty)); }
public void New_ShouldProduceSameUriThatWasGiven(string uri) { var result = FluentUriBuilder.New(uri).Build(); Assert.Equal(new Uri(uri), result); }
public void WithQueries_ShouldAddMultipleQueryParamerters() { var result = FluentUriBuilder.New("http://host:1234/test").AddQueries(new[] { "what=hey", "no=yes" }).Build(); Assert.Equal(new Uri("http://host:1234/test?what=hey&no=yes"), result); }