We have just started using ASP.Net MVC Release Candidate and the test project we have was previously testing Ajax requests with MVC beta.
The old code looked something like this:
Mock<HttpRequestBase> request = new Mock<HttpRequestBase>();
Mock<HttpResponseBase> response = new Mock<HttpResponseBase>();
Mock<HttpContextBase> context = new Mock<HttpContextBase>();
context.Expect(c => c.Request).Returns(request.Object);
context.Expect(c => c.Response).Returns(response.Object);
request.Expect(req => req["__MVCASYNCPOST"]).Returns("true");
MyController controller = new MyController();
controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
ViewResult result = controller.UpdateStatus() as ViewResult;
The call to UpdateStatus would then use the IsMvcAjaxRequest() method on the request object to determine what to return to the browser.
The change in ASP.Net MVC Release Candidate to the Request.IsMvcAjaxRequest() to an extension method of Request.IsAjaxRequest() means that the way we mock the request headers is changed to:
request.Expect(req => req["X-Requested-With"]).Returns("XMLHttpRequest");
I hope others find this useful