Here's my problem - I am using MvcMailer to create nicely formatted emails using Razor syntax, and it's a great tool to use for that!
The issue I'm running into is this - here's some syntax from my View for one of the emails i send:
<p>Click here to return to <a href="@Url.Abs(Url.Action("Details", "Home", new{ Id=ViewBag.IdeaId}))">@ViewBag.IdeaName</a></p>
Whenever I try to run my unit tests, I get the following error message:
Can we send out email notifications for new comments?: System.ArgumentNullException : Value cannot be null. Parameter name: httpContext
Stacktrace - shortened for brevity, relevant sections only:
at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) at Mvc.Mailer.MailerBase.CreateControllerContext() at Mvc.Mailer.MailerBase.ViewExists(String viewName, String masterName) at Castle.Proxies.Invocations.MailerBase_ViewExists.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed()
The issue is that my HttpContext is null - is there a straightforward way to unit test this MvcMailer method without having to mock everything from the controller context all the way down the route results?