public void WhenEndAppointment_ThenAppointmentEnded() { var client = new JsonServiceClient(ServiceUrl); var clinic = RegisterClinic(client); var doctor = client.Post(new RegisterDoctorRequest { ClinicId = clinic.Id, FirstName = "afirstname", LastName = "alastname" }).Doctor; var appointment = client.Post(new CreateAppointmentRequest { DoctorId = doctor.Id, StartUtc = DateTime.UtcNow.AddHours(1), EndUtc = DateTime.UtcNow.AddHours(2) }).Appointment; client.Patch(new EndAppointmentRequest { Id = appointment.Id }); }
public void Test_PATCH_unsupported_cast_PASS() { var restClient = new JsonServiceClient(serviceUrl); // dummy data var newemp1 = new Employee() { Id = 123, Name = "Kimo", StartDate = new DateTime(2015, 7, 2), CubicleNo = 4234, Email = "*****@*****.**", }; restClient.Post <object>("/employees", newemp1); var emps = restClient.Get <List <Employee> >("/employees"); var emp = emps.First(); var empPatch = new Operations.EmployeePatch(); // float not currently supported by this example code empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/longitude", value = "2.123", }); restClient.Patch <object>(string.Format("/employees/{0}", emp.Id), empPatch); }
public void Test_PATCH_unsupported_cast_FAIL() { var restClient = new JsonServiceClient(serviceUrl); // dummy data var newemp1 = new Employee() { Id = 123, Name = "Kimo", StartDate = new DateTime(2015, 7, 2), CubicleNo = 4234, Email = "*****@*****.**", }; restClient.Post <object>("/employees", newemp1); var emps = restClient.Get <List <Employee> >("/employees"); var emp = emps.First(); var empPatch = new Operations.EmployeePatch(); // double not currently supported by this example code empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/othernumber", value = "3.1415927", }); Assert.Throws <WebServiceException>(delegate { // InvalidCastException restClient.Patch <object>(string.Format("/employees/{0}", emp.Id), empPatch); }); }
public void Test_PATCH_PASS() { var restClient = new JsonServiceClient(serviceUrl); // register callback to grab the Location: header when executed string lastResponseLocation = ""; HttpStatusCode lastResponseStatusCode = 0; restClient.LocalHttpWebResponseFilter = httpRes => { lastResponseLocation = httpRes.Headers[HttpHeaders.Location]; lastResponseStatusCode = httpRes.StatusCode; }; // dummy data var newemp1 = new Employee() { Id = 123, Name = "Kimo", StartDate = new DateTime(2015, 7, 2), CubicleNo = 4234, Email = "*****@*****.**", }; restClient.Post <object>("/employees", newemp1); var emps = restClient.Get <List <Employee> >("/employees"); var emp = emps.First(); var empPatch = new Operations.EmployeePatch(); empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/title", value = "Kahuna Laau Lapaau", }); empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/cubicleno", value = "32", }); restClient.Patch <object>(string.Format("/employees/{0}", emp.Id), empPatch); var empAfterPatch = restClient.Get <Employee>(string.Format("/employees/{0}", emp.Id)); Assert.NotNull(empAfterPatch); // patched Assert.Equal("Kahuna Laau Lapaau", empAfterPatch.Title); Assert.Equal("32", empAfterPatch.CubicleNo.ToString()); // unpatched Assert.Equal("*****@*****.**", empAfterPatch.Email); }
public async Task M() { var client = new JsonServiceClient(""); client.DeserializeFromStream <object>(new MemoryStream()); // not a sink client.Get(new ReqDto1()); client.Get(new ReqDto2()); client.Get <ResponseDto>("relativeOrAbsoluteUrl"); // not a sink client.Get <ResponseDto>(new object()); client.Get("relativeOrAbsoluteUrl"); // not a sink client.Get(new object()); await client.GetAsync <ResponseDto>("relativeOrAbsoluteUrl"); // not a sink await client.GetAsync <ResponseDto>(new object()); await client.GetAsync(new ReqDto1()); await client.GetAsync(new ReqDto2()); client.CustomMethod("GET", new ReqDto2()); client.CustomMethod <ResponseDto>("GET", "relativeOrAbsoluteUrl", new ReqDto1()); client.CustomMethod <ResponseDto>("GET", new ReqDto1()); client.CustomMethod <ResponseDto>("GET", new object()); client.CustomMethod("GET", "relativeOrAbsoluteUrl", new object()); client.CustomMethod("GET", (IReturnVoid)null); await client.CustomMethodAsync("GET", new ReqDto2()); await client.CustomMethodAsync <ResponseDto>("GET", "relativeOrAbsoluteUrl", new ReqDto1()); await client.CustomMethodAsync <ResponseDto>("GET", new ReqDto1()); await client.CustomMethodAsync <ResponseDto>("GET", new object()); client.DownloadBytes("GET", "requestUri", new object()); await client.DownloadBytesAsync("GET", "relativeOrAbsoluteUrl", new object()); client.Head(new object()); client.Patch(new object()); client.Post(new object()); client.Put(new object()); client.Send <ResponseDto>(new object()); client.Publish(new ReqDto1()); client.SendOneWay(new object()); }
public Issue Patch(string repo, int issueId, Issue issue) { return(_client.Patch <Issue>("repos/" + repo + "/issues/" + issueId, issue.ToPatch())); }
public void Test_PATCH_PASS() { var restClient = new JsonServiceClient(serviceUrl); // register callback to grab the Location: header when executed string lastResponseLocation = ""; HttpStatusCode lastResponseStatusCode = 0; restClient.LocalHttpWebResponseFilter = httpRes => { lastResponseLocation = httpRes.Headers[HttpHeaders.Location]; lastResponseStatusCode = httpRes.StatusCode; }; // dummy data var newemp1 = new Employee() { Id = 123, Name = "Kimo", StartDate = new DateTime(2015, 7, 2), CubicleNo = 4234, Email = "*****@*****.**", }; restClient.Post<object>("/employees", newemp1); var emps = restClient.Get<List<Employee>>("/employees"); var emp = emps.First(); var empPatch = new Operations.EmployeePatch(); empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/title", value = "Kahuna Laau Lapaau", }); empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/cubicleno", value = "32", }); restClient.Patch<object>(string.Format("/employees/{0}", emp.Id), empPatch); var empAfterPatch = restClient.Get<Employee>(string.Format("/employees/{0}", emp.Id)); Assert.NotNull(empAfterPatch); // patched Assert.Equal("Kahuna Laau Lapaau", empAfterPatch.Title); Assert.Equal("32", empAfterPatch.CubicleNo.ToString()); // unpatched Assert.Equal("*****@*****.**", empAfterPatch.Email); }
public void Test_PATCH_unsupported_cast_PASS() { var restClient = new JsonServiceClient(serviceUrl); // dummy data var newemp1 = new Employee() { Id = 123, Name = "Kimo", StartDate = new DateTime(2015, 7, 2), CubicleNo = 4234, Email = "*****@*****.**", }; restClient.Post<object>("/employees", newemp1); var emps = restClient.Get<List<Employee>>("/employees"); var emp = emps.First(); var empPatch = new Operations.EmployeePatch(); // float not currently supported by this example code empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/longitude", value = "2.123", }); restClient.Patch<object>(string.Format("/employees/{0}", emp.Id), empPatch); }
public void Test_PATCH_unsupported_cast_FAIL() { var restClient = new JsonServiceClient(serviceUrl); // dummy data var newemp1 = new Employee() { Id = 123, Name = "Kimo", StartDate = new DateTime(2015, 7, 2), CubicleNo = 4234, Email = "*****@*****.**", }; restClient.Post<object>("/employees", newemp1); var emps = restClient.Get<List<Employee>>("/employees"); var emp = emps.First(); var empPatch = new Operations.EmployeePatch(); // double not currently supported by this example code empPatch.Add(new Operations.JsonPatchElement() { op = "replace", path = "/othernumber", value = "3.1415927", }); Assert.Throws<WebServiceException>(delegate { // InvalidCastException restClient.Patch<object>(string.Format("/employees/{0}", emp.Id), empPatch); }); }
public Label Patch(string repo, string labelId, Label label) { return(_client.Patch <Label>("repos/" + repo + "/labels/" + labelId, label)); }
public void CanPerform_PartialUpdate() { var client = new JsonServiceClient("http://localhost:53990/api/"); // back date for readability var created = DateTime.Now.AddHours(-2); // Create a record so we can patch it var league = new League() {Name = "BEFORE", Abbreviation = "BEFORE", DateUpdated = created, DateCreated = created}; var newLeague = client.Post<League>(league); // Update Name and DateUpdated fields. Notice I don't want to update DateCreatedField. // I also added a fake field to show it does not cause any errors var updated = DateTime.Now; newLeague.Name = "AFTER"; newLeague.Abbreviation = "AFTER"; // setting to after but it should not get updated newLeague.DateUpdated = updated; client.Patch<League>("http://localhost:53990/api/leagues/" + newLeague.Id + "?fields=Name,DateUpdated,thisFieldDoesNotExist", newLeague); var updatedLeague = client.Get<League>(newLeague); Assert.AreEqual(updatedLeague.Name, "AFTER"); Assert.AreEqual(updatedLeague.Abbreviation, "BEFORE"); Assert.AreEqual(updatedLeague.DateUpdated.ToString(), updated.ToString(), "update fields don't match"); Assert.AreEqual(updatedLeague.DateCreated.ToString(), created.ToString(), "created fields don't match"); // double check Assert.AreNotEqual(updatedLeague.DateCreated, updatedLeague.DateUpdated); }