diff Stocks/Stocks.Common/WebClientShim.cs @ 6:c812bca7b1ac

"Restore packages on build" enabled by Nuget 1.6 General refactoring based on code analysis
author stevenh7776 stevenhollidge@hotmail.com
date Tue, 21 Feb 2012 01:00:34 +0700
parents 57f20ba55884
children 6e84a4c92378
line wrap: on
line diff
--- a/Stocks/Stocks.Common/WebClientShim.cs	Mon Feb 20 23:07:37 2012 +0700
+++ b/Stocks/Stocks.Common/WebClientShim.cs	Tue Feb 21 01:00:34 2012 +0700
@@ -1,23 +1,30 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Net;
+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 readonly WebClient _webClient;
+    private WebClient _webClient;
 
     public WebClientShim(WebClient webClient)
     {
       _webClient = webClient;
     }
-    
+
+    // add event handlers to the shim if you wish 
+    // to hook into DownloadStringCompleted event
     public string DownloadString(string address)
     {
       return _webClient.DownloadString(address).ToString();
     }
+
+    public void Dispose()
+    {
+      _webClient.Dispose();
+    }
   }
-}
+}
\ No newline at end of file