Does FakeItEasy support the idea of Partial Mocks?
-
20-06-2021 - |
سؤال
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.
المحلول
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.
لا تنتمي إلى StackOverflow