Difficulty to start up with basic unit test (Sample from my book -- SportsStore)

Posted by Richard77 on Stack Overflow See other posts from Stack Overflow or by Richard77
Published on 2010-04-28T20:33:55Z Indexed on 2010/04/28 20:37 UTC
Read the original article Hit count: 283

Filed under:
|

Hello,

I'm really new in TDD and, actually, I'm trying to follow the sample from my book (SportsStore -- Pro ASP.NET MVC Framework/Steve Sanderson/APRESS). I'm on pages 103-105.

Although there are more on this, as new to all of this, I'm concerned with the following statements.

ProductsController controller = new ProductsController(repository);
var result = controller.List(2);
     //...

regarding the above statements, when I write this (as in the book),

var products = result.ViewData.Model as IList<Product>;

I get a compiler error "System.Web.MVC.ActionResult" does not contain a definition for ViewData ..." But, when I remove the List() from the statement, then the compiler error disapear.

var result = controller.List(2);//Doesn't work
var result = controller;//It works

Is something wrong there? I checked Apress website for that book, but there is nothing listed as Errata or issue. So I'm really lost.

Thanks for helping

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about unit-testing