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:
NOTE: All the test methods where you use fake-objects must mark an attribute
[TrueFake], which clean all the arrangements from other tests before current test method is started.
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>();
NOTE: 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).
Default Return Values¶
There are several rules that return values of fake-object members are instantiated:
- If the return value is
string, then such member will return
- If the return type is an interface, there is fake object for this interface will be automatically generated (please see Recursive Mocking for more details).
- In other cases, the return type is defined as a