예제 #1
0
        public void WhenPutFails_ThenThrows()
        {
            using (var ws = new HttpWebService <HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
            {
                var client = new HttpEntityConventionClient(ws.BaseUri);
                // We're putting a null which is invalid.
                var exception = Assert.Throws <HttpEntityException>(() => client.Put <Product>("25", null));

                Assert.Equal(HttpStatusCode.InternalServerError, exception.StatusCode);
            }
        }
예제 #2
0
        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);
			}
		}
		public void WhenPutFails_ThenThrows()
		{
			using (var ws = new HttpWebService<HttpEntityConventionClientTestService>("http://localhost:20000", "products", new ServiceConfiguration()))
			{
				var client = new HttpEntityConventionClient(ws.BaseUri);
				// We're putting a null which is invalid.
				var exception = Assert.Throws<HttpEntityException>(() => client.Put<Product>("25", null));

				Assert.Equal(HttpStatusCode.InternalServerError, exception.StatusCode);
			}
		}