Example #1
0
        public void WebRequest_SimpleGets(string url, string expected)
        {
            //arrange
            WebRequest request = System.Net.WebRequest.Create(url);

            //act
            Stream stream = null;
            string actual = CurlRequests.CurlBash(request, ref stream);

            //assert
            actual.Should().Be(expected);
        }
Example #2
0
        public void WebRequest_SimplePosts(string url, string data, string expected)
        {
            //arrange
            WebRequest request = System.Net.WebRequest.Create(url);

            request.Method = "POST";

            //act
            MemoryStream ms = new MemoryStream();
            var          sw = new StreamWriter(ms, Encoding.UTF8);

            sw.Write(data);
            sw.Flush();

            ms.Position = 0;
            Stream stream = ms;

            string actual = CurlRequests.CurlBash(request, ref stream);

            //assert
            actual.Should().Be(expected);
        }
Example #3
0
        public void WebRequest_Posts_Headers(string url, string data, string expected)
        {
            //arrange
            HttpWebRequest request = (HttpWebRequest)System.Net.WebRequest.Create(url);

            request.Method      = "POST";
            request.ContentType = "application/json";
            request.Accept      = "application/json";

            //act
            MemoryStream ms = new MemoryStream();
            var          sw = new StreamWriter(ms, Encoding.UTF8);

            sw.Write(data);
            sw.Flush();

            ms.Position = 0;
            Stream stream = ms;

            string actual = CurlRequests.CurlBash(request, ref stream);

            //assert
            actual.Should().Be(expected);
        }