public void TestPut() { var newUser = new UserGet { name = "Test name", job = "Test job" }; request = new RestRequest("api/users/2"); request.Method = Method.POST; request.AddJsonBody(newUser); var response = client.Execute <UserGet>(request); request = new RestRequest("api/users/2"); request.AddUrlSegment("id", response.Data.id); request.Method = Method.PUT; request.AddJsonBody(new UserGet { job = "New job" }); var result = client.Execute <UserGet>(request); Assert.AreEqual(true, response.IsSuccessful); Assert.AreEqual(result.Data.job, "New job"); }
public void TestPost() { var newUser = new UserGet { name = "Test name", job = "Test job" }; request = new RestRequest("api/users"); request.Method = Method.POST; request.AddJsonBody(newUser); var response = client.Execute <UserGet>(request); Assert.AreEqual(true, response.IsSuccessful); Assert.AreEqual(newUser.name, response.Data.name); }
public void TestDelete() { var newUser = new UserGet { name = "Test name", job = "Test job" }; request = new RestRequest("api/users/2"); request.Method = Method.POST; request.AddJsonBody(newUser); var response = client.Execute <UserGet>(request); Assert.AreEqual(true, response.IsSuccessful); request = new RestRequest("api/users/2"); request.AddUrlSegment("id", response.Data.id); request.Method = Method.DELETE; var result = client.Execute <UserGet>(request); Assert.AreEqual(result.StatusCode, HttpStatusCode.NoContent); }