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); }
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); }
/// <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); }