?

Log in

No account? Create an account

Previous Entry | Next Entry

How can we implement Mocking?

You can implement mocking by using open source mocking frameworks like Rhino mocks, MOQ etc.

For example if we want to Mock the email class method by using MOQ tool we need to write the below code. Create the email object using the Mock class of MOQ framework.

e2

Then write the code which you want to execute rather than executing the actual code. For instance now I want to just “return true” in a hard code manner.

e3


Now any calls to the “target” email object will always return true. At the last there is a video which talks about Mock testing.

So are we saying Microsoft does not have mock frameworks?

In Visual studio 2012 Microsoft has introduced “Fakes” which has two great features “Stubs” and “Shims” which will help us achieve mock testing.

Copy right www.questpond.com

Tags

Latest Month

September 2017
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
Powered by LiveJournal.com