Saturday 15 March 2014

c# - Unit testing controller method property -


I am working via Apress via Pro ASP.NET MVC 4 and used specifically in unit testing Trying to understand the syntax is the controller method.

A class some controller :

  Looking at a controller method for the public view list (Intel®) {ViewModel Model = New ViewModel {ModelObject = New Model Object {Object Property = Some; }} View Return (Model); } Unit Testing looks like this:  
  [test method] some (some) method () ... the name of the fake object is 'fake' SomeController target = new SomeController (Fake Object); // This is the next line, where the syntax is corrupting me int result = (ViewModel) target.List (1). Model). ModelObject.ObjectProperty; Assurance First (result, 1); }   

It is almost like ViewResult.Model , type of 'cast' type should be in the form of ViewModel or something else I am sure this is a name for syntax / technique and I would like to know more about what is happening here.

Is this technique necessary because something like this:

  integer = goal. List (1) Model Model Object Objectproperty;   

Does not work for the pass model to be able to reach the properties of the object?

This method is simply a simple insert embedded in the series. target.List (int) returns a type as an object so that any model can be used. To type this your ViewModel , it is necessary to tell the custardier in your test how the model is equal to:

  See Model Model = (see modal) target.list (1). Model; Int results = model. MODELObject.ObjectProperty;    

No comments:

Post a Comment