view Stocks/Stocks.Common/WebClientShim.cs @ 12:6a0449185449

SCC changed from TFS to HG
author stevenh7776 stevenhollidge@hotmail.com
date Tue, 21 Feb 2012 17:47:35 +0700
parents 6e84a4c92378
children
line wrap: on
line source

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();
    }
  }
}