?

Log in

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

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com