Пример #1
0
        public static HttpRequestMessage CreatePostJsonRequest(string uri, object data)
        {
            var request = new HttpRequestMessage(HttpMethod.Post, uri);

            request.AcceptJson();
            request.SetJsonContent(data);
            return(request);
        }
        public void AcceptJson_WithNoParams_ShouldAppendAcceptJsonHeader()
        {
            // Setup
            var request = new HttpRequestMessage();

            // Perform action 'AcceptJson'
            request.AcceptJson();

            var header = request.Headers.FirstOrDefault(h => h.Key == "Accept");

            // Assert that 'ShouldAppendAcceptJsonHeader' = 'WithNoParams'
            Assert.NotNull(header);
            Assert.Equal("application/json", header.Value.FirstOrDefault());
        }