public void WhenGetFails_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.Get <Product>("25")); Assert.Equal(HttpStatusCode.NotFound, exception.StatusCode); } }
public void WhenDeletingEntity_ThenGetFails() { using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); client.Delete<Product>("1"); var exception = Assert.Throws<HttpEntityException>(() => client.Get<Product>("25")); Assert.Equal(HttpStatusCode.NotFound, exception.StatusCode); } }
public void WhenGetting_ThenRetrieves() { using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var product = client.Get<Product>("1"); Assert.NotNull(product); Assert.Equal("kzu", product.Owner.Name); } }
public void WhenGetting_ThenRetrieves() { using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var product = client.Get <Product>("1"); Assert.NotNull(product); Assert.Equal("kzu", product.Owner.Name); } }
public void WhenPutUpdate_ThenSaves() { using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", true, new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var product = new Product { Id = 1, Owner = new User { Id = 1, Name = "vga" } }; client.Put("1", product); var saved = client.Get <Product>("1"); Assert.Equal(saved.Owner.Name, product.Owner.Name); } }
public void WhenPutNew_ThenSaves() { using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", true, new ServiceConfiguration())) { var client = new HttpEntityConventionClient(ws.BaseUri); var product = new Product { Owner = new User { Id = 1, Name = "kzu" } }; client.Put("4", product); var saved = client.Get<Product>("4"); Assert.Equal(saved.Id, 4); Assert.Equal(saved.Owner.Id, product.Owner.Id); Assert.Equal(saved.Owner.Name, product.Owner.Name); } }