asp.net - Is there any way to get all data retrieved between two points in C# code (Linq-to-sql) -
my cenario follow: i'm working in 1 system developed in c# asp.net (a big, huge , definetly grown anyway system). , i'm trying begin create unit tests start refactor (believe, it's need refactor (there controllers 10k, 12k lines). problem lot of things in system related database (and system tightly coupled database). database context instantiated in lot of pieces of code, , not injected. so, point mock data local mdb file refactor code , create unit tests have own mdb (with database structure, data use).
in though? that:
[testmethod()] public void anytest() { var dblogger = new dblogger(); //this class not created, it's example. dblogger.start(); worstwrittenmethodever(); //this method call other methods insides, //a couple of //and don't know order , //complexity (much times high), , //instantiate datacontext lot of times , //a lot of data retrieval. db.stoplog(); console.writeline(db.dataretrieved); //and in line print tables //and data retrieved between 2 points. }
after that, data, mock 1 mdb file, , refactor unit test above unit test.
is there anyway that?
looks not easy task. , think should use popular , tested library or tool. recommendation use miniprofiler. allows capture sql queries (also includes support of linqtosql). has ui , api interact within code. sql queries data can use following method:
miniprofiler.current.getsqltimings();
Comments
Post a Comment