Esempio n. 1
0
        public void ToUrl_WithNullSegments_ReturnsEmptyString()
        {
            IEnumerable <string> segments = null;

            var formattedUrl = UrlSerializer.ToUrl(segments, true);

            Assert.AreEqual(string.Empty, formattedUrl);
        }
Esempio n. 2
0
        public void ToUrl_WithNullParameters_ReturnsTemplate()
        {
            string template = "test/{test}";

            var formattedUrl = UrlSerializer.ToUrl(template, null);

            Assert.AreEqual(template, formattedUrl);
        }
Esempio n. 3
0
        public void ToUrl_WithNullTemplate_ReturnsEmptyString()
        {
            string template = null;

            var formattedUrl = UrlSerializer.ToUrl(template, new object());

            Assert.AreEqual(string.Empty, formattedUrl);
        }
Esempio n. 4
0
        public void ToUrl_WithTemplateRequirementsThatAreNotInParameters_Ignores()
        {
            string template = "test/{test}";

            var formattedUrl = UrlSerializer.ToUrl(template, new object());

            Assert.AreEqual(template, formattedUrl);
        }
Esempio n. 5
0
        public void ToUrl_WithParametersThatAreNotInTemplate_Skips()
        {
            string template = "test";

            var formattedUrl = UrlSerializer.ToUrl(template, new
            {
                test = "as df"
            });

            Assert.AreEqual(template, formattedUrl);
        }
Esempio n. 6
0
        public void ToUrl_WithParametersThatNeedSerializing_Serialize()
        {
            string template = "test/{test}";
            string expected = "test/as%20df";

            var formattedUrl = UrlSerializer.ToUrl(template, new
            {
                test = "as df"
            });

            Assert.AreEqual(expected, formattedUrl);
        }
Esempio n. 7
0
        public void ToUrl_WithInvalidSegments_ReturnsEscapedUrl()
        {
            var segments = new[]
            {
                "as d f",
                "g oog",
                "wo2"
            };

            string finalUrl = "as%20d%20f/g%20oog/wo2";

            var formattedUrl = UrlSerializer.ToUrl(segments, true);

            Assert.AreEqual(finalUrl, formattedUrl);
        }
Esempio n. 8
0
        public void ToUrl_WithValidSegments_ReturnsUrl()
        {
            var segments = new[]
            {
                "asdf",
                "goog",
                "wo2"
            };

            string finalUrl = string.Join("/", segments);

            var formattedUrl = UrlSerializer.ToUrl(segments, true);

            Assert.AreEqual(finalUrl, formattedUrl);
        }
Esempio n. 9
0
        /// <summary>
        /// Set the relative path for the request
        /// </summary>
        /// <param name="sanitiseSegments">Whether to Uri sanitise each of the path segments</param>
        /// <param name="pathSegments">The path segments to use</param>
        /// <returns>This <see cref="FluentRequestUrl"/></returns>
        public FluentRequestUrl Path(bool sanitiseSegments, IEnumerable <string> pathSegments)
        {
            pathUrl = UrlSerializer.ToUrl(pathSegments, sanitiseSegments);

            return(this);
        }
Esempio n. 10
0
        /// <summary>
        /// Set the relative path for the request
        /// </summary>
        /// <param name="pathTemplate">The path template to use (such as "api/people/{id}")</param>
        /// <param name="parameters">The object to overlay onto the path template</param>
        /// <returns>This <see cref="FluentRequestUrl"/></returns>
        public FluentRequestUrl Path(string pathTemplate, object parameters)
        {
            pathUrl = UrlSerializer.ToUrl(pathTemplate, parameters);

            return(this);
        }