What are you testing? or perhaps How are you testing it?
In general, you should be testing the controllers, to ensure correct view,
viewdata, etc. You should also test any components you have added, along
with your business logic, which should be in libraries. If your libraries
call data, etc., you should mock it.
As to your particular error, it looks like you are instantiating data, which
probably pulls from the web.config. This is not unit testing, it is
integration testing. nUnit will not read the web.config, so the data
contexts will fail every time unless you use something like a mock object.
nUnit has rudimentary mocks, mbUnit uses RhinoMocks.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
********************************************
| Think outside the box! |
********************************************
"Mark Elliott" <ya**********@hotmail.comwrote in message
news:op***************@aka-wk04.eastlink.ca...
Hi All,
I'm just playing with asp.net mvc and link-to-sql for the first time. I'm
using visual web developer 2008. I create the project fine, choose nunit
as my test framework in the wizard. Everything is fine, compiles and the
tests work fine on the basic application. However once I add some linq
things to it, and specifically the line:
WestoriaDataContext westoria = new WestoriaDataContext();
Now when I try to run tests in nunit it fails with a bunch "object
reference not set to an instance of an object" errors. The site itself
runs fine, the code is fine from what I can tell. Anybody using nunit
experience this or know what I might be missing?
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/