public async Task TestPost() { //arrange Restaurant rest = new Restaurant(); rest.Name = "Xpto"; rest.CountryId = 1; rest.Address = "1234, Road Street"; //act var ret = await client.CreateAsync(rest); //assert Assert.AreEqual(rest.Name, ret.Name); }
public async Task TestDelete() { //arrange Restaurant rest = new Restaurant(); rest.Name = "Test DeleteAsync Restaurant"; rest.CountryId = 1; rest.Address = "1234, Road Street"; //Creates the new restaurant var ret = await client.CreateAsync(rest); //act Assert.DoesNotThrow(async() => await client.DeleteAsync(ret.Id)); try { //assert that deleted restaurant doesn't exist anymore var test = await this.client.GetOneAsync(ret.Id, "get"); Assert.Fail("WebApiException expected"); } catch (WebApiClientException e) { Assert.AreEqual(HttpStatusCode.NotFound, e.StatusCode); } }
public async Task TestCreateTooShortTimeoutUsingOptions() { //arrange Restaurant rest = new Restaurant(); rest.Name = "Xpto"; rest.CountryId = 1; rest.Address = "1234, Road Street"; try { var resp = await client.CreateAsync(rest); Assert.Fail(); } catch (WebApiClientException e) { Assert.AreEqual(HttpStatusCode.RequestTimeout, e.StatusCode); } }