ASP.Net MVC RC Unit Testing Ajax Requests -


The

We use yet Aspiknet MVC Release Candidate test project started, we first MVC Beta Along with Ajax requests were tested.

The old code has seen something like this:

  fake & lt; HttpRequestBase & gt; Request = new fake & lt; HttpRequestBase & gt; (); Fake & lt; HttpResponseBase & gt; Feedback = new mask & lt; Htppspacebase & gt; (); Fake & lt; HttpContextBase & gt; Context = new fake & lt; HttpContextBase & gt; (); Context.Expect (c => c.Request). Return (request.Object); Context.Expect (c => c.response). Response.Object; Request ((================================================ ================================================== ======================================================== MyController = New MyController (); controller. Niyntrksnsadn = new Niyntrksngeet (Ref. object, new Rutadeta (), controller); ViewResult result = controller. UpdateStatus () as ViewResult;  

Call UpdateStatus shall use IsMvcAjaxRequest () method on the request object, it is to determine whether the return to the browser.

ASP.Net MVC changes Request.IsMvcAjaxRequest (in) Article Release the candidate to insertion. The extension of ISAJxRuest () means the method that we duplicate the requested headers, it changes them:

  request.Expect ( req = & gt; request [ "X-requested-with"]) Return ( "XMLHttpRequest") .;  

I hope that others will find it useful

< / Div>

I knew there was a change in Scott GU's blog, but it was a request for an AJAX request. Fake test code or thought does not provide any code examples of the value that this release could provide a quick and simple fix for this change candidate.


Comments