예제 #1
0
        public async Task Can_post_raw_response_as_raw_JSON_HttpClient()
        {
            var httpClient = new JsonHttpClient(BaseUrl);
            var request    = new GetCustomer {
                CustomerId = 5
            };
            var response = httpClient.Post(request);

            Assert.That(response.Customer.Id, Is.EqualTo(5));

            var requestPath = request.ToPostUrl();

            string json = request.ToJson();

            response = await httpClient.PostAsync <GetCustomerResponse>(requestPath, json);

            Assert.That(response.Customer.Id, Is.EqualTo(5));

            byte[] bytes = json.ToUtf8Bytes();
            response = await httpClient.PutAsync <GetCustomerResponse>(requestPath, bytes);

            Assert.That(response.Customer.Id, Is.EqualTo(5));

            Stream ms = bytes.InMemoryStream();

            response = await httpClient.PostAsync <GetCustomerResponse>(requestPath, ms);

            Assert.That(response.Customer.Id, Is.EqualTo(5));
        }
예제 #2
0
        public void Can_post_raw_response_as_raw_JSON()
        {
            var request = new GetCustomer {
                CustomerId = 5
            };
            var response = client.Post(request);

            Assert.That(response.Customer.Id, Is.EqualTo(5));

            var requestPath = request.ToPostUrl();

            string json = request.ToJson();

            response = client.Post <GetCustomerResponse>(requestPath, json);
            Assert.That(response.Customer.Id, Is.EqualTo(5));

            byte[] bytes = json.ToUtf8Bytes();
            response = client.Put <GetCustomerResponse>(requestPath, bytes);
            Assert.That(response.Customer.Id, Is.EqualTo(5));

            Stream ms = bytes.InMemoryStream();

            response = client.Post <GetCustomerResponse>(requestPath, ms);
            Assert.That(response.Customer.Id, Is.EqualTo(5));
        }