public void WhenSerializedAndContentEmptyThenReturnsEmptyString()
        {
            // we expect values to have been encoded
            var content = new Dictionary <string, string>();

            var stringContent = new FormUrlEncodedContent(content);

            stringContent.Serialize().Should().Be(string.Empty);
        }
Ejemplo n.º 2
0
            public void SetsTheContentFromFormUrlContent()
            {
                FormUrlEncodedContent formContent = new FormUrlEncodedContent(
                    new Dictionary <string, string> {
                    ["test-1"] = "test-1", ["test-2"] = "test-2"
                });
                HttpConnectRequest request = CreatePostRequest(content: formContent);

                HttpRequestMessage httpRequestMessage = _middleware.BuildRequestMessageTester(request);

                httpRequestMessage.Content.Headers.GetValues("Content-Type").Single().Should().Be("application/x-www-form-urlencoded");
                string content = httpRequestMessage.Content.ReadAsStringAsync().Result;

                content.Should().Be(formContent.Serialize());
            }
        public void WhenSerializedThenReturnsFormUrlEncodedSerializedContent()
        {
            // we expect values to have been encoded
            var content = new Dictionary <string, string>
            {
                ["test-1"] = "test 1",
                ["test-2"] = "test 2",
                ["test-3"] = "",
                ["test 4"] = "test 4",
                ["test-5"] = "test-5"
            };
            string expected = "test-1=test+1&test-2=test+2&test-3=&test+4=test+4&test-5=test-5";

            var stringContent = new FormUrlEncodedContent(content);

            stringContent.Serialize().Should().Be(expected);
        }