public void SetPathToEmpty() { var url = new UrlBuilder("http://www.shoutem.com/nid/"); url.SetPath(string.Empty); Assert.AreEqual("http://www.shoutem.com/", url.ToString()); }
public void AddPathSegment() { var url = new UrlBuilder("http://www.shoutem.com/app"); url.AddPathSegment("nid"); Assert.AreEqual("app/nid", url.GetPath()); }
public void SetHost() { var url = new UrlBuilder(); url.SetHost("www.shoutem.com"); Assert.AreEqual("www.shoutem.com", url.GetHost()); }
public void RemoveSegmentWithTrailingSlash() { var url = new UrlBuilder("http://www.shoutem.com/app/nid/"); url.RemovePathSegment("nid"); Assert.AreEqual("app/", url.GetPath()); }
public void SetPathWithTrailingSlash() { var url = new UrlBuilder("http://www.shoutem.com/nid"); url.SetPath("app/nid/"); Assert.AreEqual("app/nid/", url.GetPath()); }
public void SetPort() { var url = new UrlBuilder(); url.SetPort(443); Assert.AreEqual(443, url.GetPort()); }
public void ChangePort() { var url = new UrlBuilder("www.shoutem.com"); url.SetPort(443); Assert.AreEqual(443, url.GetPort()); }
public void ChangeScheme() { var url = new UrlBuilder("http://www.shoutem.com"); url.SetScheme(Uri.UriSchemeHttps); Assert.AreEqual(Uri.UriSchemeHttps, url.GetScheme()); }
public void SetSchemeToEmpty() { var url = new UrlBuilder("www.shoutem.com"); url.SetScheme(string.Empty); Assert.AreEqual(string.Empty, url.GetScheme()); }
public void SetSchemeToNull() { var url = new UrlBuilder("www.shoutem.com"); url.SetScheme(null); Assert.AreEqual(null, url.GetScheme()); }
public void SetScheme() { var url = new UrlBuilder("www.shoutem.com"); url.SetScheme(Uri.UriSchemeHttp); Assert.AreEqual(Uri.UriSchemeHttp, url.GetScheme()); }
public void SetHostNull() { var url = new UrlBuilder("http://www.shoutem.com/"); url.SetHost(null); Assert.AreEqual(null, url.GetHost()); }
public void SetTrailingSlash() { var url = new UrlBuilder("http://www.shoutem.com/nid"); url.AddPathSegment("/"); Assert.AreEqual("http://www.shoutem.com/nid/", url.ToString()); }
public void ChangeHost() { var url = new UrlBuilder("http://www.shoutem.com/"); url.SetHost("www.shoutem.local"); Assert.AreEqual("www.shoutem.local", url.GetHost()); }
public void SetHostEmpty() { var url = new UrlBuilder("http://www.shoutem.com/"); url.SetHost(string.Empty); Assert.AreEqual(string.Empty, url.GetHost()); }
public void RemovePathSegment() { var url = new UrlBuilder("http://www.shoutem.com/app"); url.RemovePathSegment("app"); Assert.AreEqual(string.Empty, url.GetPath()); }
public void SetQueryParamToNull() { var url = new UrlBuilder("http://www.shoutem.com/app"); url.SetQueryParam("nid", null); var param = url.GetQueryParam("nid"); Assert.AreEqual(null, param); }
public void AppendQueryParam() { var url = new UrlBuilder("http://www.shoutem.com/app"); url.AppendQueryParam("nid", 123); var param = url.GetQueryParam("nid"); Assert.AreEqual("123", param.ToString()); }
public void SetQueryParamToEmtpy() { var url = new UrlBuilder("http://www.shoutem.com/app"); url.SetQueryParam("nid", string.Empty); var param = url.GetQueryParam("nid"); Assert.AreEqual(string.Empty, param.ToString()); }
public void SetExistingQueryParam() { var url = new UrlBuilder("http://www.shoutem.com/app?nid=123"); url.SetQueryParam("nid", 321); var param = url.GetQueryParam("nid"); Assert.AreEqual("321", param.ToString()); }
public void DefaultSchemeFromUrl() { var url1 = new UrlBuilder("http://www.shoutem.com"); var url2 = new UrlBuilder("https://www.shoutem.com"); var url3 = new UrlBuilder("ftp://www.shoutem.com"); Assert.AreEqual(Uri.UriSchemeHttp, url1.GetScheme()); Assert.AreEqual(Uri.UriSchemeHttps, url2.GetScheme()); Assert.AreEqual(Uri.UriSchemeFtp, url3.GetScheme()); }
public void DefaultPortsForSchemes() { var url1 = new UrlBuilder("http://www.shoutem.com/"); var url2 = new UrlBuilder("https://www.shoutem.com/"); var url3 = new UrlBuilder("ftp://www.shoutem.com/"); Assert.AreEqual(80, url1.GetPort()); Assert.AreEqual(443, url2.GetPort()); Assert.AreEqual(21, url3.GetPort()); }
public void AppendExistingQueryParam() { var url = new UrlBuilder("http://www.shoutem.com/app"); url.SetQueryParam("role", "moderator"); url.AppendQueryParam("role", "admin"); var paramList = url.GetQueryParam("role") as IList<object>; var param1 = paramList[0]; var param2 = paramList[1]; Assert.AreEqual("moderator", param1.ToString()); Assert.AreEqual("admin", param2.ToString()); }
public void ContainsQueryParamNull() { var url = new UrlBuilder("http://www.shoutem.com/app?nid=123&role=admin"); Assert.AreEqual(false, url.ContainsQueryParam(null)); }
/// <summary> /// Constructs a UrlBuilder object from a urlBuilder. /// </summary> /// <param name="urlBuilder">The urlBuilder to use as a starting point (required)</param> public UrlBuilder(UrlBuilder urlBuilder) { if (urlBuilder == null) { throw new ArgumentNullException("urlBuilder"); } Initialize(urlBuilder.ToString()); }
public void RemoveQueryParam() { var url = new UrlBuilder("http://www.shoutem.com/app?nid=123"); url.RemoveQueryParam("nid"); Assert.AreEqual(false, url.ContainsQueryParam("nid")); }
public void SetQueryParams() { var url = new UrlBuilder("http://www.shoutem.com/app"); var dictParams = new Dictionary<string, object> {{"nid", 123}, {"role", "admin"}}; url.SetQueryParams(dictParams); var param1 = url.GetQueryParam("nid"); var param2 = url.GetQueryParam("role"); Assert.AreEqual("123", param1.ToString()); Assert.AreEqual("admin", param2.ToString()); }
public void UrlBuilderWithTrailingSlash() { var url = new UrlBuilder("http://www.shoutem.com/nid/"); Assert.AreEqual("http://www.shoutem.com/nid/", url.ToString()); }
public void DefaultHost() { var url = new UrlBuilder("http://www.shoutem.com/"); Assert.AreEqual("www.shoutem.com", url.GetHost()); }
public void DefaultHostWithoutUrl() { var url = new UrlBuilder(); Assert.AreEqual("localhost", url.GetHost()); }