diff MetroWpf/Stocks.Common/WebClientShim.cs @ 20:6109bc268b90

Latest
author adminsh@apollo
date Tue, 20 Mar 2012 13:37:46 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/Stocks.Common/WebClientShim.cs	Tue Mar 20 13:37:46 2012 +0000
@@ -0,0 +1,28 @@
+using System.Net;
+using System;
+
+namespace Stocks.Common
+{
+  // Shim to wrap WebClient component to allow the shim to 
+  // be mocked or stubbed for unit tests.
+  // Favours injection and composition over inheritence
+  public class WebClientShim : IWebClientShim
+  {
+    private WebClient _webClient;
+
+    public WebClientShim(WebClient webClient)
+    {
+      _webClient = webClient;
+    }
+
+    public string DownloadString(string address)
+    {
+      return _webClient.DownloadString(address).ToString();
+    }
+
+    public void Dispose()
+    {
+      _webClient.Dispose();
+    }
+  }
+}
\ No newline at end of file