public void ShouldPOSTWithJsonData() { using (FakeHttpServer server = new FakeHttpServer("http://localhost:8080/api/customers")) { var bodyExtractor = new JsonBodyExtractor <TestCustomer>(); server.UseBodyExtractor(bodyExtractor); server.Listen(); RestClient client = new RestClient(); var response = client.Post("http://localhost:8080/api/customers") .WithJsonBody(new TestCustomer() { Name = "Bob Smith", Age = 31, Title = "Mr." }) .Execute(); var customer = bodyExtractor.Result; Assert.AreEqual("Bob Smith", customer.Name, "The name was not sent."); Assert.AreEqual(31, customer.Age, "The age was not sent."); Assert.AreEqual("Mr.", customer.Title, "The title was not sent."); } }
public void ShouldPOSTWithJsonData() { using (FakeHttpServer server = new FakeHttpServer("http://localhost:8080/api/customers")) { var bodyExtractor = new JsonBodyExtractor<TestCustomer>(); server.UseBodyExtractor(bodyExtractor); server.Listen(); RestClient client = new RestClient(); var response = client.Post("http://localhost:8080/api/customers") .WithJsonBody(new TestCustomer() { Name = "Bob Smith", Age = 31, Title = "Mr." }) .Execute(); var customer = bodyExtractor.Result; Assert.AreEqual("Bob Smith", customer.Name, "The name was not sent."); Assert.AreEqual(31, customer.Age, "The age was not sent."); Assert.AreEqual("Mr.", customer.Title, "The title was not sent."); } }