public void CreateOrder() { responseHeaders.Location = new Uri("http://restbucks.com/order/123456"); mockServer.ExpectNewRequest() .AndExpectUri("http://restbuckson.net/orders") .AndExpectMethod(HttpMethod.POST) .AndExpectBody("<order xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://restbucks.com\"><location>inShop</location><items><item><name>Latte</name><quantity>1</quantity></item></items></order>") .AndRespondWith("", responseHeaders); Order order = new Order() { Location = "inShop", Items = new List<OrderItem>() { new OrderItem() { Name = "Latte", Quantity = 1 } } }; Uri uri = restBucksClient.CreateOrder(order); Assert.AreEqual(responseHeaders.Location, uri); }
// Methods public Uri CreateOrder(Order order) { return restTemplate.PostForLocation("orders", order); }