0
moqContext = new Mock<HttpContextBase>();
moqRequest = new Mock<HttpRequestBase>();
moqRequest.Setup(x => x.QueryString).Returns(new NameValueCollection {{"email", "[email protected]"}});
moqRequest.Setup(x => x.HttpMethod).Returns("Get");
moqRequest.Setup(x => x.Headers).Returns(new System.Net.WebHeaderCollection
{
{"Host", "localhost"},
{"Content-MD5", "123456abcd"},
{"Content-Type", "application/x-www-form-urlencoded"},
{"Date", DateTime.Now.ToString(CultureInfo.CurrentCulture)},
});
moqContext.Setup(x => x.Request).Returns(moqRequest.Object);
ConfidentialeController controller = new ConfidentialeController{ControllerContext = new HttpControllerContext()};
コントローラのWeb APIにHttpContextBaseを模擬することができます)二つの異なるタイプどのように私は(HttpControllerContextをコンストラクタに私のmoqContextを設定することはできません