This repository has been archived by the owner on Jul 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Fakes
Matthias Koch edited this page Aug 8, 2015
·
13 revisions
When testing components or units in isolation, it is a common prerequisite to create and setup fakes. After enabling the FakeItEasyTestExtension
(available in TestFx.FakeItEasy) you can declaratively dispatch this task to SpecK:
[Faked] IServiceProvider ServiceProvider;
[Faked] [ReturnedFrom ("ServiceProvider")] object Service;
When using the Faked
attribute, fields will be initialized with A.Fake<T>()
, which is shown in the overview as <Create_Fakes>
. By adding the ReturnedFrom
attribute the ServiceProvider
will be setup with A.CallTo(ServiceProvider).WithReturnType<object>().Returns(Service)
, which is shown as <Setup_Fakes>
.
Both features play nicely with the subject creation feature, so that you can mark all interface dependencies as [Injected] [Faked]
.