title: How to mock UmbracoContext for unit testing?
body: <p>I am writing unit tests for ASP.NET MVC application using RhinoMocks and Umbraco. For this I need to mock UmbracoContext, and so used below code.
  But Umbraco.Core.ApplicationContext.Current throws ArgumentNullException. Please suggest resolution for this:</p>
  
  <pre><code>var contextBase = MockRepository.GenerateMock&lt;HttpContextBase&gt;();
  var request = MockRepository.GenerateMock&lt;HttpRequestBase&gt;();
  var response = MockRepository.GenerateMock&lt;HttpResponseBase&gt;();
  var session = MockRepository.GenerateMock&lt;HttpSessionStateBase&gt;();
  var server = MockRepository.GenerateMock&lt;HttpServerUtilityBase&gt;();
  
  contextBase.Stub(ctx =&gt; ctx.Request).Return(request);
  contextBase.Stub(ctx =&gt; ctx.Response).Return(response);
  contextBase.Stub(ctx =&gt; ctx.Session).Return(session);
  contextBase.Stub(ctx =&gt; ctx.Server).Return(server);
  
  var umbracoCtx = UmbracoContext.EnsureContext(contextBase, Umbraco.Core.ApplicationContext.Current);
  </code></pre>