public void HttpRequestWithBody_Should_Not_Allow_Body_For_Request_With_Field() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); var stream = new MemoryStream(); Post.field(stream); Delete.field(stream); Patch.field(stream); Put.field(stream); Action addBodyPost = () => Post.body("test"); Action addBodyDelete = () => Delete.body("test"); Action addBodyPatch = () => Patch.body("test"); Action addBodyPut = () => Put.body("test"); Action addObjectBodyPost = () => Post.body(1); Action addObjectBodyDelete = () => Delete.body(1); Action addObjectBodyPatch = () => Patch.body(1); Action addObjectBodyPut = () => Put.body(1); addBodyPost.ShouldThrow <InvalidOperationException>(); addBodyDelete.ShouldThrow <InvalidOperationException>(); addBodyPatch.ShouldThrow <InvalidOperationException>(); addBodyPut.ShouldThrow <InvalidOperationException>(); addObjectBodyPost.ShouldThrow <InvalidOperationException>(); addObjectBodyDelete.ShouldThrow <InvalidOperationException>(); addObjectBodyPatch.ShouldThrow <InvalidOperationException>(); addObjectBodyPut.ShouldThrow <InvalidOperationException>(); }
public void Http_Request_Shouldnt_Add_Body_To_Get() { var Get = new HttpRequest(HttpMethod.Get, "http://localhost"); Action addStringBody = () => Get.body("string"); Action addJSONBody = () => Get.body(new List <int> { 1, 2, 3 }); addStringBody.ShouldThrow <InvalidOperationException>(); addJSONBody.ShouldThrow <InvalidOperationException>(); }
public void HttpRequestWithBody_Should_Add_JSON_Body() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); Post.body(new List <int> { 1, 2, 3 }); Delete.body(new List <int> { 1, 2, 3 }); Patch.body(new List <int> { 1, 2, 3 }); Put.body(new List <int> { 1, 2, 3 }); Post.Body.Should().NotBeEmpty(); Delete.Body.Should().NotBeEmpty(); Patch.Body.Should().NotBeEmpty(); Put.Body.Should().NotBeEmpty(); }
public void HttpRequestWithBody_Should_Not_Allow_Fields_For_Request_With_Body() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); var stream = new MemoryStream(); Post.body("test"); Delete.body("test"); Patch.body("test"); Put.body("lalala"); Action addFieldPost = () => Post.field("key", "value"); Action addFieldDelete = () => Delete.field("key", "value"); Action addFieldPatch = () => Patch.field("key", "value"); Action addFieldPut = () => Put.field("key", "value"); Action addStreamFieldPost = () => Post.field(stream); Action addStreamFieldDelete = () => Delete.field(stream); Action addStreamFieldPatch = () => Patch.field(stream); Action addStreamFieldPut = () => Put.field(stream); Action addFieldsPost = () => Post.fields(new Dictionary <string, object> { { "test", "test" } }); Action addFieldsDelete = () => Delete.fields(new Dictionary <string, object> { { "test", "test" } }); Action addFieldsPatch = () => Patch.fields(new Dictionary <string, object> { { "test", "test" } }); Action addFieldsPut = () => Put.fields(new Dictionary <string, object> { { "test", "test" } }); addFieldPost.ShouldThrow <InvalidOperationException>(); addFieldDelete.ShouldThrow <InvalidOperationException>(); addFieldPatch.ShouldThrow <InvalidOperationException>(); addFieldPut.ShouldThrow <InvalidOperationException>(); addStreamFieldPost.ShouldThrow <InvalidOperationException>(); addStreamFieldDelete.ShouldThrow <InvalidOperationException>(); addStreamFieldPatch.ShouldThrow <InvalidOperationException>(); addStreamFieldPut.ShouldThrow <InvalidOperationException>(); addFieldsPost.ShouldThrow <InvalidOperationException>(); addFieldsDelete.ShouldThrow <InvalidOperationException>(); addFieldsPatch.ShouldThrow <InvalidOperationException>(); addFieldsPut.ShouldThrow <InvalidOperationException>(); }
public static void HttpRequestWithBody_Should_Add_String_Body() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); Post.body("test"); Delete.body("test"); Patch.body("test"); Put.body("test"); Assert.NotEmpty(Post.Body); Assert.NotEmpty(Delete.Body); Assert.NotEmpty(Patch.Body); Assert.NotEmpty(Put.Body); }
public static void HttpRequestWithBody_Should_Add_String_Body() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); Post.body("test"); Delete.body("test"); Patch.body("test"); Put.body("test"); Post.Body.Should().NotBe(string.Empty); Delete.Body.Should().NotBe(string.Empty); Patch.Body.Should().NotBe(string.Empty); Put.Body.Should().NotBe(string.Empty); }
public static void HttpRequestWithBody_Should_Not_Allow_Body_For_Request_With_Field() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); var stream = new MemoryStream(); Post.field(stream); Delete.field(stream); Patch.field(stream); Put.field(stream); Action addBodyPost = () => Post.body("test"); Action addBodyDelete = () => Delete.body("test"); Action addBodyPatch = () => Patch.body("test"); Action addBodyPut = () => Put.body("test"); Action addObjectBodyPost = () => Post.body(1); Action addObjectBodyDelete = () => Delete.body(1); Action addObjectBodyPatch = () => Patch.body(1); Action addObjectBodyPut = () => Put.body(1); addBodyPost.ShouldThrow<InvalidOperationException>(); addBodyDelete.ShouldThrow<InvalidOperationException>(); addBodyPatch.ShouldThrow<InvalidOperationException>(); addBodyPut.ShouldThrow<InvalidOperationException>(); addObjectBodyPost.ShouldThrow<InvalidOperationException>(); addObjectBodyDelete.ShouldThrow<InvalidOperationException>(); addObjectBodyPatch.ShouldThrow<InvalidOperationException>(); addObjectBodyPut.ShouldThrow<InvalidOperationException>(); }
public static void Http_Request_Shouldnt_Add_Body_To_Get() { var Get = new HttpRequest(HttpMethod.Get, "http://localhost"); Action addStringBody = () => Get.body("string"); Action addJSONBody = () => Get.body(new List<int> {1,2,3}); addStringBody.ShouldThrow<InvalidOperationException>(); addJSONBody.ShouldThrow<InvalidOperationException>(); }
public static void HttpRequestWithBody_Should_Not_Allow_Fields_For_Request_With_Body() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); var stream = new MemoryStream(); Post.body("test"); Delete.body("test"); Patch.body("test"); Put.body("lalala"); Action addFieldPost = () => Post.field("key", "value"); Action addFieldDelete = () => Delete.field("key", "value"); Action addFieldPatch = () => Patch.field("key", "value"); Action addFieldPut = () => Put.field("key", "value"); Action addStreamFieldPost = () => Post.field(stream); Action addStreamFieldDelete = () => Delete.field(stream); Action addStreamFieldPatch = () => Patch.field(stream); Action addStreamFieldPut = () => Put.field(stream); Action addFieldsPost = () => Post.fields(new Dictionary<string, object> {{"test", "test"}}); Action addFieldsDelete = () => Delete.fields(new Dictionary<string, object> {{"test", "test"}}); Action addFieldsPatch = () => Patch.fields(new Dictionary<string, object> {{"test", "test"}}); Action addFieldsPut = () => Put.fields(new Dictionary<string, object> {{"test", "test"}}); addFieldPost.ShouldThrow<InvalidOperationException>(); addFieldDelete.ShouldThrow<InvalidOperationException>(); addFieldPatch.ShouldThrow<InvalidOperationException>(); addFieldPut.ShouldThrow<InvalidOperationException>(); addStreamFieldPost.ShouldThrow<InvalidOperationException>(); addStreamFieldDelete.ShouldThrow<InvalidOperationException>(); addStreamFieldPatch.ShouldThrow<InvalidOperationException>(); addStreamFieldPut.ShouldThrow<InvalidOperationException>(); addFieldsPost.ShouldThrow<InvalidOperationException>(); addFieldsDelete.ShouldThrow<InvalidOperationException>(); addFieldsPatch.ShouldThrow<InvalidOperationException>(); addFieldsPut.ShouldThrow<InvalidOperationException>(); }
public static void HttpRequestWithBody_Should_Add_JSON_Body() { var Post = new HttpRequest(HttpMethod.Post, "http://localhost"); var Delete = new HttpRequest(HttpMethod.Delete, "http://localhost"); var Patch = new HttpRequest(new HttpMethod("PATCH"), "http://localhost"); var Put = new HttpRequest(HttpMethod.Put, "http://localhost"); Post.body(new List<int> { 1, 2, 3 }); Delete.body(new List<int> { 1, 2, 3 }); Patch.body(new List<int> { 1, 2, 3 }); Put.body(new List<int> { 1, 2, 3 }); Post.Body.Should().NotBeEmpty(); Delete.Body.Should().NotBeEmpty(); Patch.Body.Should().NotBeEmpty(); Put.Body.Should().NotBeEmpty(); }