<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to Mock HttpWebRequest when Unit Testing</title>
	<atom:link href="http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/</link>
	<description>SalamanderSoft, SharePoint Learning Kit, Microsoft Learning Gateway &#38; SharePoint Development</description>
	<lastBuildDate>Thu, 29 Jul 2010 00:13:50 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Gordon Weakliem</title>
		<link>http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/comment-page-1/#comment-140</link>
		<dc:creator>Gordon Weakliem</dc:creator>
		<pubDate>Fri, 04 Jun 2010 19:52:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/#comment-140</guid>
		<description>The answer to the StatusCode problem is to implement the cast operator to create a HttpWebResponse around your fake WebResponse.  Unfortunately, that&#039;s messing around in internal code.  You can get there through reflection, but it&#039;s ugly.</description>
		<content:encoded><![CDATA[<p>The answer to the StatusCode problem is to implement the cast operator to create a HttpWebResponse around your fake WebResponse.  Unfortunately, that&#8217;s messing around in internal code.  You can get there through reflection, but it&#8217;s ugly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mwb</title>
		<link>http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/comment-page-1/#comment-129</link>
		<dc:creator>mwb</dc:creator>
		<pubDate>Fri, 19 Feb 2010 20:58:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/#comment-129</guid>
		<description>Awesomely useful post for unit testers.  Unfortunately, my ObjectUnderTest gets a HttpWebReponse and checks the StatusCode, which is read-only and not override-able.</description>
		<content:encoded><![CDATA[<p>Awesomely useful post for unit testers.  Unfortunately, my ObjectUnderTest gets a HttpWebReponse and checks the StatusCode, which is read-only and not override-able.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/comment-page-1/#comment-121</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Tue, 12 Jan 2010 00:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/#comment-121</guid>
		<description>Here&#039;s a quick example which posts some data to a url and get the response. You can test the input in TestWebRequest.GetRequestStream.

public void DoStuff()
{
            WebRequest request = WebRequest.Create(this.Url);  
            request.Method = &quot;POST&quot;;  
            request.ContentType = &quot;application/x-www-form-urlencoded&quot;;  
              
            // Create the data we want to send  
            string token = &quot;tokenValue&quot;;  
            string method = &quot;handle&quot;;
              
            string format = &quot;token={0}&amp;method={1}&amp;xml={2}&quot;;
            string data = string.Format(CultureInfo.InvariantCulture, format, HttpUtility.UrlEncode(token), HttpUtility.UrlEncode(method), HttpUtility.UrlEncode(GeneratePayload()));  

            byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());  
            request.ContentLength = byteData.Length;  
              
            using (Stream postStream = request.GetRequestStream())  
            {  
                postStream.Write(byteData, 0, byteData.Length);  
            }  
              
            using (WebResponse response = request.GetResponse())  
            {
                 // Do something with the response
             }
}</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a quick example which posts some data to a url and get the response. You can test the input in TestWebRequest.GetRequestStream.</p>
<p>public void DoStuff()<br />
{<br />
            WebRequest request = WebRequest.Create(this.Url);<br />
            request.Method = &#8220;POST&#8221;;<br />
            request.ContentType = &#8220;application/x-www-form-urlencoded&#8221;;  </p>
<p>            // Create the data we want to send<br />
            string token = &#8220;tokenValue&#8221;;<br />
            string method = &#8220;handle&#8221;;</p>
<p>            string format = &#8220;token={0}&amp;method={1}&amp;xml={2}&#8221;;<br />
            string data = string.Format(CultureInfo.InvariantCulture, format, HttpUtility.UrlEncode(token), HttpUtility.UrlEncode(method), HttpUtility.UrlEncode(GeneratePayload()));  </p>
<p>            byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());<br />
            request.ContentLength = byteData.Length;  </p>
<p>            using (Stream postStream = request.GetRequestStream())<br />
            {<br />
                postStream.Write(byteData, 0, byteData.Length);<br />
            }  </p>
<p>            using (WebResponse response = request.GetResponse())<br />
            {<br />
                 // Do something with the response<br />
             }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/comment-page-1/#comment-116</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Thu, 31 Dec 2009 08:02:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/#comment-116</guid>
		<description>Have you got an example of the code inside ObjectUnderTest</description>
		<content:encoded><![CDATA[<p>Have you got an example of the code inside ObjectUnderTest</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thys</title>
		<link>http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/comment-page-1/#comment-112</link>
		<dc:creator>Thys</dc:creator>
		<pubDate>Tue, 01 Dec 2009 15:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.salamandersoft.co.uk/index.php/2009/10/how-to-mock-httpwebrequest-when-unit-testing/#comment-112</guid>
		<description>Hi

Good article, just what I needed!

Cheers</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>Good article, just what I needed!</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
</channel>
</rss>
