Beispiel #1
0
        public void UrlGeneration()
        {
            RequestBuilder rb = RequestBuilder.InitiateRequest("http://baseurl.com/");

            rb.AddPath("path1");
            rb.AddPath("path2");
            rb.AddQuery("key1", null);
            rb.AddQuery("key2", "value2");
            rb.SetResource("test.html");

            string expectedUrl = "http://baseurl.com/path1/path2/test.html?key1&key2=value2";

            Assert.AreEqual <string>(expectedUrl, rb.AssembledUrl);
        }
Beispiel #2
0
        public void CloneCreatesNewInstanceOfBuilder()
        {
            var builder     = new RequestBuilder(_testUrl);
            var builderCopy = builder.Clone();

            builder = (RequestBuilder)builder.AddPath("testing");

            Assert.Equal(_testUrl, (builderCopy as RequestBuilder)?.GetRequest().ToString());
            Assert.Equal($"{_testUrl}/testing", builder.GetRequest().ToString());
            Assert.NotEqual(builder, builderCopy);
        }
Beispiel #3
0
 /// <summary>
 /// Creates a <c>RequestBuilder</c> with the path to the resource.
 /// </summary>
 /// <example>
 /// <code>
 ///     var builder = new RequestBuilder("/whoami");
 /// </code>
 /// </example>
 ///
 /// <param name="path">Path to the resource</param>
 /// <returns><c>RequestBuilder</c> instance.</returns>
 public virtual RequestBuilder RequestBuilder(string path)
 {
     _builder.Reset();
     _builder.AddPath(path);
     return(_builder);
 }