コード例 #1
0
        public void SetPathToEmpty()
        {
            var url = new UrlBuilder("http://www.shoutem.com/nid/");
            url.SetPath(string.Empty);

            Assert.AreEqual("http://www.shoutem.com/", url.ToString());
        }
コード例 #2
0
        public void AddPathSegment()
        {
            var url = new UrlBuilder("http://www.shoutem.com/app");
            url.AddPathSegment("nid");

            Assert.AreEqual("app/nid", url.GetPath());
        }
コード例 #3
0
        public void SetHost()
        {
            var url = new UrlBuilder();
            url.SetHost("www.shoutem.com");

            Assert.AreEqual("www.shoutem.com", url.GetHost());
        }
コード例 #4
0
        public void RemoveSegmentWithTrailingSlash()
        {
            var url = new UrlBuilder("http://www.shoutem.com/app/nid/");
            url.RemovePathSegment("nid");

            Assert.AreEqual("app/", url.GetPath());
        }
コード例 #5
0
        public void SetPathWithTrailingSlash()
        {
            var url = new UrlBuilder("http://www.shoutem.com/nid");
            url.SetPath("app/nid/");

            Assert.AreEqual("app/nid/", url.GetPath());
        }
コード例 #6
0
        public void SetPort()
        {
            var url = new UrlBuilder();
            url.SetPort(443);

            Assert.AreEqual(443, url.GetPort());
        }
コード例 #7
0
        public void ChangePort()
        {
            var url = new UrlBuilder("www.shoutem.com");
            url.SetPort(443);

            Assert.AreEqual(443, url.GetPort());
        }
コード例 #8
0
        public void ChangeScheme()
        {
            var url = new UrlBuilder("http://www.shoutem.com");
            url.SetScheme(Uri.UriSchemeHttps);

            Assert.AreEqual(Uri.UriSchemeHttps, url.GetScheme());
        }
コード例 #9
0
        public void SetSchemeToEmpty()
        {
            var url = new UrlBuilder("www.shoutem.com");
            url.SetScheme(string.Empty);

            Assert.AreEqual(string.Empty, url.GetScheme());
        }
コード例 #10
0
        public void SetSchemeToNull()
        {
            var url = new UrlBuilder("www.shoutem.com");
            url.SetScheme(null);

            Assert.AreEqual(null, url.GetScheme());
        }
コード例 #11
0
        public void SetScheme()
        {
            var url = new UrlBuilder("www.shoutem.com");
            url.SetScheme(Uri.UriSchemeHttp);

            Assert.AreEqual(Uri.UriSchemeHttp, url.GetScheme());
        }
コード例 #12
0
        public void SetHostNull()
        {
            var url = new UrlBuilder("http://www.shoutem.com/");
            url.SetHost(null);

            Assert.AreEqual(null, url.GetHost());
        }
コード例 #13
0
        public void SetTrailingSlash()
        {
            var url = new UrlBuilder("http://www.shoutem.com/nid");
            url.AddPathSegment("/");

            Assert.AreEqual("http://www.shoutem.com/nid/", url.ToString());
        }
コード例 #14
0
        public void ChangeHost()
        {
            var url = new UrlBuilder("http://www.shoutem.com/");
            url.SetHost("www.shoutem.local");

            Assert.AreEqual("www.shoutem.local", url.GetHost());
        }
コード例 #15
0
        public void SetHostEmpty()
        {
            var url = new UrlBuilder("http://www.shoutem.com/");
            url.SetHost(string.Empty);

            Assert.AreEqual(string.Empty, url.GetHost());
        }
コード例 #16
0
        public void RemovePathSegment()
        {
            var url = new UrlBuilder("http://www.shoutem.com/app");
            url.RemovePathSegment("app");

            Assert.AreEqual(string.Empty, url.GetPath());
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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());
        }
コード例 #19
0
        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());
        }
コード例 #20
0
        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());
        }
コード例 #21
0
        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());
        }
コード例 #22
0
        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());
        }
コード例 #23
0
        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());
        }
コード例 #24
0
        public void ContainsQueryParamNull()
        {
            var url = new UrlBuilder("http://www.shoutem.com/app?nid=123&role=admin");

            Assert.AreEqual(false, url.ContainsQueryParam(null));
        }
コード例 #25
0
        /// <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());
        }
コード例 #26
0
        public void RemoveQueryParam()
        {
            var url = new UrlBuilder("http://www.shoutem.com/app?nid=123");
            url.RemoveQueryParam("nid");

            Assert.AreEqual(false, url.ContainsQueryParam("nid"));
        }
コード例 #27
0
        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());
        }
コード例 #28
0
 public void UrlBuilderWithTrailingSlash()
 {
     var url = new UrlBuilder("http://www.shoutem.com/nid/");
     Assert.AreEqual("http://www.shoutem.com/nid/", url.ToString());
 }
コード例 #29
0
        public void DefaultHost()
        {
            var url = new UrlBuilder("http://www.shoutem.com/");

            Assert.AreEqual("www.shoutem.com", url.GetHost());
        }
コード例 #30
0
        public void DefaultHostWithoutUrl()
        {
            var url = new UrlBuilder();

            Assert.AreEqual("localhost", url.GetHost());
        }