This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static HtmlHelper CreateHtmlHelper(ViewDataDictionary vd) | |
{ | |
Mock mockViewContext = new Mock( | |
new ControllerContext( | |
new Mock().Object, | |
new RouteData(), | |
new Mock().Object), | |
new Mock().Object, | |
vd, | |
new TempDataDictionary(), | |
new Mock().Object); | |
var mockViewDataContainer = new Mock(); | |
mockViewDataContainer.Setup(v => v.ViewData) | |
.Returns(vd); | |
return new HtmlHelper(mockViewContext.Object, | |
mockViewDataContainer.Object); | |
} |
[...] http://ox.no/posts/mocking-htmlhelper-in-asp-net-mvc-2-and-3-using-moq [...]
ReplyDeleteThanks for the example, it was great.
ReplyDelete