Search code examples
asp.net-mvcunit-testingnunitmoqhtml-helper

How to Unit Test HtmlHelper with Moq?


Could somebody show me how you would go about creating a mock HTML Helper with Moq?

This article has a link to an article claiming to describe this, but following the link only returns an ASP.NET Runtime Error

[edit] I asked a more specific question related to the same subject here, but it hasn't gotten any responses. I figured it was too specific, so I thought I could get a more general answer to a more general question and modify it to meet my requirements.

Thanks


Solution

  • What you can do is this:

    HtmlHelper helper = null;
    helper.YourHelperMethod();
    

    No need to mock anything. Works brilliant for me.