I'm trying to use FakeItEasy 2.0.0 to fake a property in a simple interface:
public interface IPerson
{
int Age { set; }
}
Note that I don't have a get accessor. The test I'm trying to write is:
public void SetsAge()
{
var fakePerson = A.Fake<IPerson>();
A.CallToSet(() => fakePerson.Age).To(42).MustHaveHappened();
fakePerson.Age = 42;
}
But the line containing A.CallToSet fails to compile with:
which is fairly self-explanatory, but confusing since I'm not trying to get the property's value.
Do I have to provide a get accessor to get this to compile (even though I don't want a get accessor)? What is the reason that it requires the get accessor in this case (the same compiler error happens when I replace MustHaveHappened with DoesNothing)? Or am I doing something fundamentally wrong?
Or perhaps I shouldn't lose too much sleep over this and do the right thing in the first place?