public void Should_Build_Currect_Url() { string result; result = FluentUrl.New("http://www.google.com").Path().Build(); result.ShouldBe("http://www.google.com"); result = FluentUrl.New("http://www.google.com?id=1").Path().Build(); result.ShouldBe("http://www.google.com?id=1"); result = FluentUrl.New("http://www.google.com?id=1").Path("test").Build(); result.ShouldBe("http://www.google.com/test?id=1"); result = FluentUrl.New("http://www.google.com/?id=1").Path("test").Build(); result.ShouldBe("http://www.google.com/test?id=1"); result = FluentUrl.New("http://www.google.com/?id=1").Path("test", "/hello/").QueryString("id", 2).Build(); result.ShouldBe("http://www.google.com/test/hello/?id=1&id=2"); result = FluentUrl.New("http://www.google.com/?id=1").QueryString("id", 2).Build(); result.ShouldBe("http://www.google.com/?id=1&id=2"); result = FluentUrl.New("http://www.google.com").Path("test", "hello") .QueryString("id", "e r") .QueryString("isTrue", true) .Build(); result.ShouldBe("http://www.google.com/test/hello?id=e%20r&isTrue=true"); }
public static FluentUrl State(this FluentUrl url, string stateCode) { if (!stateCode.IsNullOrEmpty()) { url.Section("State", "stateCode", stateCode.ToUrlSectionString()); } return(url); }
public static FluentUrl WithPaging(this FluentUrl url, int pageNumber) { if (pageNumber > 1) { url.Section("WithPaging", "pageNumber", pageNumber); } return(url); }
public static FluentUrl Name(this FluentUrl url, string name) { if (!name.IsNullOrEmpty()) { url.Section("Name", "name", name.ToUrlSectionString()); } return(url); }
public static FluentUrl DetailsId(this FluentUrl url, long id) { if (id > (long)0) { url.Section("DetailsId", new { id = id }); } return(url); }
public static FluentUrl City(this FluentUrl url, string cityName) { if (!cityName.IsNullOrEmpty()) { url.Section("City", "cityName", cityName.ToUrlSectionString()); } return(url); }
public static FluentUrl Address(this FluentUrl url, string address) { if (!address.IsNullOrEmpty()) { url.Section("Address", "address", address.ToUrlSectionString()); } return(url); }
public static FluentUrl Zip(this FluentUrl url, string zip) { if (!zip.IsNullOrEmpty()) { url.Section("Zip", "zip", zip.ToUrlSectionString()); } return(url); }
public static FluentUrl Api(this FluentUrl url, string action, string controller, object routeValues) { if (!action.IsNullOrEmpty() && !controller.IsNullOrEmpty()) { url.Section("Default", new { action = action, controller = controller }); if (routeValues != null) { url.Section(string.Empty, routeValues); } } return(url); }
public static FluentUrl PrintDirection(this FluentUrl url) { url.Section("PrintDirection"); return(url); }