The 'Services Without Components' trick means I can use
transactions for tests. I usually avoid the hassle and
just live with a restore before each test, but sometimes
this means a suite of tests takes several minutes to
run, which is too long when you're anxious to see if you
broke anything with your last change.
Nice work!
The SWC rollback method doesn't work here. After the
teardown code has run, a value inserted into the
database is still there. XP SP2...
Roy,
This is a good article. Would I be able to test my
transaction handling code inside the COM+ transaction.
Lets say I want to test that when inserting an Order and
related order lines and an order line insert fails that
the order insert is rolled back? Will that test work
within the COM+ transaction?
Also, it would be great to see you expand the article to
include the TransactionScope object in .Net 2.0.
Bob
Rollback does work... but you have to open the
connection to the database _after_ opening the new
transaction context. Thanks to Roy for setting me
straight!
Nice article - best solution I've seen for db testing.
However, you missed one important point.
If you use RESTORE how do you ensure your views/stored
procedures/stored functions/etc are up to date.
If you don't use RESTORE how do you ensure the initial
data state?
Finally found the time to read through the whole thing -
it's great in concept, although when I tried to
implement a a similar scheme (with XtUnit) a while back
I couldn't get it to work (COM+ errors I did not readily
know what to do with).
I'll definitely give this a shot next time I write a DAL
in .NET (which may be a while yet...)