c# - TransactionScope causing blocking? -


i'm writing unit tests against database, , we're using transactions make sure our test data gets removed @ end.

i'm running problem methods i'm testing using own transactionscope objects, , seems blocking when hitting database.

this inside test's base class:

basescope = new committabletransaction(new transactionoptions() { isolationlevel = isolationlevel.readuncommitted, timeout = new system.timespan(0, 5, 0) }); 

and inside method i'm testing, does:

using (transactionscope scope = new transactionscope()) 

the first time code inside 2nd scope touches database, hangs. have way around problem?

if using database not doing unit testing, , problems experiencing 1 of reason why true unit testing uses mocks , stubs.

now tests doing valuable, , in cases them instead of unit testing. label integration testing (eit). key point here find whole new class of bugs when working real thing not unit test mocks. , key here real thing. fake environment artifical transaction scopes etc. losing of benefit of eit because don't catch subtle interaction errors, or (as in case) introduce artificial problems.

i find way populate database sufficient test data, , restore state outside test. "reset known state" script helpful these kind of tests.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -