Overview of Fakes Assembly

Yesterday when I was creating a project and looking at the References node I saw the command “Add Fakes Assembly”. I had some knowledge of it but it has faded away, so I reviewed it again. Whatever I had learned I will share with you.

When you right-click on any assembly you will see this option. This command only exists for Visual Studio 2012 and 2013 except I am not sure about Visual Studio 2015 Preview since I haven't looked into the Visual Studio 2015 IDE yet.

Fakes Assembly

What the Microsoft Fakes Framework is

The Microsoft Fakes framework is used for unit testing purposes. It is relevant in any functionality that is not completed yet or is based on some external factors and the values vary on every request. When you click on “Add Fakes Assembly” it will create the same assembly again with the Fakes keyword added that we will use for our testing purposes.

Add Fakes Assembly

The Fakes framework uses delegates-based methods for writing code. There are the following two types in the Fakes Framework:

Stub: the Stub type is used for many kinds of classes and interfaces that have overridable methods.

Shim: the Shim type is used for many kinds of static, sealed and non overridable methods.

I hope this will provide you some overview about Fakes. I know it's very basic but I am still learning it, when I will learn more about this I will share this again.

Up Next
    Ebook Download
    View all
    Learn
    View all