public void TestBadHttpMethod() { IRestClient client = RestClientFactory.Create(); var inputResource = new RestResource<Person>(RestResourceType.Json) { Body = new Person { Name = "Joe Bloe", Age = 41 } }; var serviceUri = new Uri(integrationServiceUri + "/home/index/1"); try { RestResource<Person> outputResource = client.PostAsync<Person, Person>(serviceUri, inputResource).Result; Assert.That(outputResource, Is.Not.Null); } catch (AggregateException ex) { var unwrappedException = ex.InnerException as HttpException; Assert.IsNotNull(unwrappedException); Assert.That(unwrappedException.GetHttpCode(), Is.EqualTo((int) HttpStatusCode.MethodNotAllowed)); throw unwrappedException; } }
public void TestInvalidResourceType() { IRestClient client = RestClientFactory.Create(); var inputResource = new RestResource<Person>(RestResourceType.None) { Body = new Person { Name = "Joe Bloe", Age = 41 } }; var serviceUri = new Uri(integrationServiceUri + "/home/index/1"); try { RestResource<Person> outputResource = client.PostAsync<Person, Person>(serviceUri, inputResource).Result; Assert.That(outputResource, Is.Not.Null); } catch (AggregateException ex) { throw ex.InnerException; } }
public void TestPatchMethod_Xml() { IRestClient client = RestClientFactory.Create(); var inputResource = new RestResource<Person>(RestResourceType.Xml) { Body = new Person { Name = "Joe Bloe", Age = 41 }, XmlNamespace = PersonXmlNamespace }; var serviceUri = new Uri(integrationServiceUri + "/home/index/1"); RestResource<Person> outputResource = client.PatchAsync<Person, Person>(serviceUri, inputResource).Result; Assert.That(outputResource, Is.Not.Null); Assert.That(outputResource.Type, Is.EqualTo(RestResourceType.Xml)); Assert.That(outputResource.StatusCode, Is.EqualTo(HttpStatusCode.OK)); Assert.That(outputResource.Body, Is.Not.Null); Assert.That(outputResource.Body.Name, Is.EqualTo(inputResource.Body.Name)); Assert.That(outputResource.Body.Age, Is.EqualTo(inputResource.Body.Age)); Assert.That(outputResource.Body.Values, Is.Not.Null); }