What's the best approach for doing this? I've got my mocks all in place etc, but when I've come across trying to Unit Test a controller that exposes a public StateValue<string>, I've come unstuck, so to speak! This is because it is never populated
by ObjectBuilder, so I get NullReferenceException errors.
Presumably I need to get ObjectBuilder to populate my StateValue objects... but does this have any knock-on effects? And what should I put in place from an infrastructure point of view? i.e do I need to register services etc?
Any help appreciated!
Apr 9, 2007 at 3:04 PM
The StateValue allows you to use the ASP.NET Session and still keep you classes testable. So for testing the controllers, what you have to do is populate yours StateValue fields, for example:
CustomersController controller = new CustomersController();
controller._customers = new StateValue<List<Customer>>(new List<Customer>(1));
Customer customerInDataStore = new Customer(1000, "Enrique", "Gil", false);
where _customers: public StateValue<List<Customer>> _customers;
You can see an example of this in the PageFlowQuickstarts included in WCSF Source Code package.
Let me know if this helps,