コード例 #1
0
		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);
			}
		}
コード例 #2
0
        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);
            }
        }
コード例 #3
0
		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);
			}
		}
コード例 #4
0
        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);
            }
        }