1
寫一些單元測試,並沒有找到一種方法來moq出使用mvc3,moq和mvccontrib useragent字符串。任何想法如何嘲笑與moq和mvccontrib useragent字符串?mvc3 moq mvccontrib如何moq useragent?
我一直在做這個,但useragent屬性是隻讀的。
public static RouteController GetRouteController()
{
var controller = new RouteController();
var builder = new TestControllerBuilder();
builder.HttpContext.Request.UserAgent = "foo-agent";
//mocks up the asp pipeline (http context, asp session, etc)
builder.InitializeController(controller);
return controller;
}