Publisher

Category

Price

Versions

Published On

Tags

True Fakes

Getting Started

Let's start True Fakes features overview with a description of the interface that will be used in the following examples. Suppose that we develop a simple vector graphics editor. Lets define the IShape interface that represents the geometric shape:

When writing unit tests often necessary to isolate test class (system under test) from all its dependencies. For this there are special stub classes (fake-classes), simulating the expected behavior. In the following sections we will look at the syntax and capabilities to work with fake-class generated for the IShape interface.

Creating a Fake

All framework classes and interfaces are located in the TrueFakes namespace. So do not forget to add it to you test class: using TrueFakes;

NOTE: All the test methods where you use fake-objects must mark an attribute [TrueFake], which clean all the arrangements after test method is completed.

If you need to simulate any aspect of the dependence behavior you can create fake-object for it as follows:

var shapeFake = TrueFake.Of<IShape>();

Current True Fakes version supports fake-objects generation only from interfaces. We work hard to give you capability to generate fake-object from other types of entities (abstract, static, sealed classes etc).

For more information about all True Fakes features such as arranging, checking received calls, raising an event etc. please follow the documentation here.