public void Setting_method_by_enum() { IHttpRequestBuilder builder = new DefaultHttpRequestBuilder(); builder.WithMethod(HttpMethod.Get); builder.WithUri("http://foo.bar/1"); var result = builder.Build(); result.Method.ShouldBe(HttpMethod.Get); }
public void Throws_if_missing_method() { IHttpRequestBuilder builder = new DefaultHttpRequestBuilder(); builder.WithUri("http://foo.bar/1"); builder.WithBody("foobar!"); Should.Throw<ArgumentNullException>(() => { builder.Build(); }); }
public void Setting_uri_by_uri() { IHttpRequestBuilder builder = new DefaultHttpRequestBuilder(); builder.WithMethod(HttpMethod.Get); builder.WithUri(new Uri("http://foo.bar/1")); var result = builder.Build(); result.CanonicalUri.ToString().ShouldBe("http://foo.bar/1"); }
public void Setting_body_content_type() { IHttpRequestBuilder builder = new DefaultHttpRequestBuilder(); builder.WithMethod(HttpMethod.Get); builder.WithUri("http://foo.bar/1?qux=baz"); builder.WithBodyContentType("application/foobar"); var result = builder.Build(); result.BodyContentType.ShouldBe("application/foobar"); result.HasBody.ShouldBeFalse(); }
public void Setting_body() { IHttpRequestBuilder builder = new DefaultHttpRequestBuilder(); builder.WithMethod(HttpMethod.Get); builder.WithUri("http://foo.bar/1?qux=baz"); builder.WithBody("foobar!"); var result = builder.Build(); result.Body.ShouldBe("foobar!"); result.HasBody.ShouldBeTrue(); }
public void Setting_headers() { IHttpRequestBuilder builder = new DefaultHttpRequestBuilder(); builder.WithMethod(HttpMethod.Get); builder.WithUri("http://foo.bar/1?qux=baz"); var fakeHeaders = new Dictionary<string, object>() { ["Accept"] = "bar", ["baz"] = 123 }; builder.WithHeaders(fakeHeaders); var result = builder.Build(); result.Headers.Count().ShouldBe(2); result.Headers.Accept.ShouldBe("bar"); }