Is it possible to use Moq to mock an object that implements an interface and abstract class?
I.e.:
public class MyClass: SomeAbstractClass, IMyClass
Your question does not really make sense. Moq can be used to mock abstract classes and interfaces. Since MyClass
is neither then you cannot create a mock of it.
I don't think this is a problem though, since consumers of your MyClass instance will probably be expecting a SomeAbstractClass
or an IMyClass
instance and not a MyClass
instance. If indeed they expect a MyClass
instance, then you need to make some abstraction on top of it. This can be achieved by either having SomeAbstractClass
implement the IMyClass
interface, or by having the IMyClass
interface expose the methods and properties of SomeAbstractClass
.