I have a base class that has a bool property which looks like this:
public abstract class MyBaseClass
{
public bool InProgress { get; protected set; }
}
I ran into this problem while writing unit tests. I was attempting to mock the behavior of a database to return a new object from a repository instead of actually connecting to a database.
Make sure your object has a usable constructor. You may not be able to successfully instantiate that object the way you want to. Ensure if you using a lambda to point to a constructor that the constructor can be called in the same way in a normal instantiation statement.
i.e.
return x => new FakeObject();
say in the case of
var fake = new FakeObject();
would not work then the lambda will also fail so be careful.