tags:

views:

17

answers:

1

Hi,

I have a .NET 3.5 Win Form application with three classes login.cs,Main.cs,dBTansaction.cs. I am writing a testcase to for Main.cs which makes calls to dbTransaction.cs. So I mocked to DBTransaction.cs to return diff values for each call and it all works fine. After the testcase is run in my teardown, i close the application for which it calls the login.cs to check if user is allowed to close application. This login.cs also makes call to DBTransaction.cs and since i mocked this class in testcase it throws an exception saying unexpected call.

How do i reset the mock objec to redirect to the original DBTRansactio.cs when called from TearDown.

Thanks

A: 

If you're writing a unit test for main.cs, then all of its dependencies (login and dbtransaction) should be mocked. You're already mocking dbtransation. I suggest you mock out your login as well so you don't have to worry about any external dependencies in your tests.

Patrick Steele