asp.net mvc - Asserting return type of MVC Controller Action -


How can you say that when a system is wrapped, an expected type is returned. Runtime type?

As part of a large unit test, to verify that the correct parameters and action filters of a given action have been specified, as I am pushing against a population example of MethodInfo when I claim against "action.ReturnParameter", it fails because it is saying that this type is System.RunTimeType although I understand that it is a cover around the expected type, I think wrap The example is relatively kind - it is the best way that I have taken so far against the name or full name, but it is terrible because it is just using "magic strings".

Can anyone help? Since nothing has been useful in my Google searches, I think that this is a really easy solution, I am not seeing it.

The code is as follows:

  [TestMethod] Public Zero checkActionFilterSet () {MethodInfo action = New Customer Controller (New MockHttpContext (.) Object) .GetType () GetMethods (BindingFlags.Public | BindingFlags.Instance). Where (mi = & gt; mi.Name.Equals ("search")) first (); Responsibility That is the parameter (type of action parameter., Type of inst. (Typef (seeRisalt)), "see results should be of expected type"); }  

The exception message is:

See the result should be of the expected type

Expected: Example

& Lt; System.Web.Mvc.ViewResult & gt;

& lt; System.Runtime Type & gt; Just call the controller method and check the type of returned object:

  var results = new customer controller (new MockHttpContext ()) object. Search (....); It is (the result, instantinst (typewrite)), "See results should be of expected type");  

If you want you can also see the value of ViewData / Model ...


Comments