public void WhenPostFails_ThenThrows() { using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var exception = Assert.Throws<HttpEntityException>(() => client.Post<Product>(null)); Assert.Equal(HttpStatusCode.InternalServerError, exception.StatusCode); } }
public void WhenPostFails_ThenThrows() { using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var exception = Assert.Throws <HttpEntityException>(() => client.Post <Product>(null)); Assert.Equal(HttpStatusCode.InternalServerError, exception.StatusCode); } }
public void WhenPostNew_ThenSavesAndRetrievesId() { using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var product = new Product { Owner = new User { Id = 1, Name = "kzu" } }; var saved = client.Post(product); Assert.Equal(4, saved.Id); Assert.Equal(saved.Owner.Id, product.Owner.Id); Assert.Equal(saved.Owner.Name, product.Owner.Name); } }
public void WhenPostNew_ThenSavesAndRetrievesId() { using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var product = new Product { Owner = new User { Id = 1, Name = "kzu" } }; var saved = client.Post(product); Assert.Equal(4, saved.Id); Assert.Equal(saved.Owner.Id, product.Owner.Id); Assert.Equal(saved.Owner.Name, product.Owner.Name); } }