Here is my problem - I use MvcMailer to create beautifully formatted emails using Razor syntax, and this is a great tool to use for this
The problem I'm encountering is some sort of syntax from my view for one of the emails I am sending:
<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, the following error message appears:
Can we send email notifications for new comments ?: System.ArgumentNullException: value cannot be null. Parameter Name: httpContext
Stacktrace - abbreviated for brevity, only for the relevant sections:
in System.Web.Routing.RouteCollection.GetRouteData (HttpContextBase httpContext) in Mvc.Mailer.MailerBase.CreateControllerContext () in Mvc.Mailer.MailerBase.ViewExists (String viewName, String masterName) in Castle.OnMetes.Omementses ) in Castle.DynamicProxy.AbstractInvocation.Proceed ()
The problem is that my HttpContext is null - is there a simple way to unit test the MvcMailer method without having to mock the entire controller context up to the route results?
nunit moq asp.net-mvc-3 razor mvcmailer
Aaronontheweb
source share