Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A

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.


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.


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.

Tags: c# fakes and shims interview questions, c# mock testing interview questions, csharp interview questions, information technology questions, programming interview questions, unit testing interview questions

  • Stored Procedure in SQL Server.

    Stored Procedure in SQL Server Stored Procedure is collection of Sql code that can be saved under a name in SSMS(Sql Server Management Studio).…

  • SQL Server: - Extended Events

    What is Extended Events? SQL Server Extended Events helps the database administrator to collect the information necessary to identify performance…

  • SQL Server - Stored Procedure

    In this article we will understand what is the use and why do we need Stored Procedure. What is Stored Procedures? A stored Procedure is a set of…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded