Re: Reflection and code replacement.
Bobby Heid <[email protected]> Sat, 21 Mar 2009 20:37:50 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
Davy, We use TypeMock (www.typemock.com) at work. With this tool, we can mock the db calls (or any other object/method). Check it out. Bobby -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of Davy J Sent: Friday, February 27, 2009 9:15 AM To: [email protected] Subject: Re: [ADVANCED-DOTNET] Reflection and code replacement. That's the problem I can't use a database in the unit tests, the project is continously built in about four different scenarios, it's extreamly dificult to test it without running the ASP.NET page. I guess I can just stop the test at the point of the first exception and test that the exception returned is the one expected. But it seams to be a poor mans unit test then. Dave. On Fri, Feb 27, 2009 at 3:10 PM, John Warner <[email protected]> wrote: > Can't answer your question. An alternate approach if I understand you > correctly (and a good chance I don't) when testing the inserts use 'odd' > values so the DBA at the back end can just run a delete query to clear > 'you' out when the test cycle is done. In case the reflection option does > not pan out... > > John Warner > > > > -----Original Message----- > > From: Discussion of advanced .NET topics. [mailto:ADVANCED- > > [email protected]] On Behalf Of Davy J > > Sent: Friday, February 27, 2009 8:59 AM > > To: [email protected] > > Subject: [ADVANCED-DOTNET] Reflection and code replacement. > > > > Hi, > > > > I'm currently writing unit tests against an existing website which I'm > not > > able to modify the source of. > > > > I've run into a problem where I need to test a method that is trying to > > insert a record into the database. > > > > Is there anyway of doing reflection / emit to replace the save method of > the > > db class with either an anoymous delegate or copy the class definition > and > > override the class implementations so that nothing happens? > > > > > > sort of: > > > > DbInstance.Save = delegate(BusinessObject bo){ > > return true; > > } > > > > =================================== > > View archives and manage your subscription(s) at > > http://peach.ease.lsoft.com/archives > > =================================== > View archives and manage your subscription(s) at > http://peach.ease.lsoft.com/archives > =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives