Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does FakeItEasy support the idea of Partial Mocks?

Similar to this question about NSubstitute, I want to know if one is able to implement partial mocks using the FakeItEasy library.

FakeItEasy seems to have an overall nicer syntax than moq (like the strongly-typed way the former deals with passing parameters to a constructor of a faked class). I'm thinking about switching to FakeItEasy, but I really need partial mock support.

like image 546
rsenna Avatar asked Jul 13 '12 15:07

rsenna


1 Answers

Yes. Syntax is no different than regular fake:

var fake = A.Fake<Fake>();
A.CallTo(() => fake.SomeMethod()).CallBaseMethod();

Or, to override all calls with base calls:

var fake = A.Fake<Fake>();
A.CallTo(fake).CallBaseMethod();

Edit Just to make clear: the fake object must be created over a concrete class.

like image 67
k.m Avatar answered Oct 13 '22 00:10

k.m